Ruby Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Ruby
Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
SFTP
SMTP
Socket / SSL
Spider
SSH
SSH Key
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Email Object
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
DH Key Exchange
DSA

Unreleased...
LZW
Icon

 

 

 

 

 

 

 

XML Encryption using 128-Bit AES Encryption

Ruby script demonstrating how to AES encrypt and decrypt content in an XML document.

Download Ruby Programming Example Scripts

# file: xmlEncryption.rb
# 
# Demonstrates how to 128-bit AES encrypt content in an XML document

require 'chilkat'

# The Chilkat XML parser for Ruby is freeware.  The code demonstrated in this
# example can be used in both commercial and non-commercial applications without 
# restriction.  

# Some Chilkat XML Ruby examples utilize these online XML data samples:
# http://www.chilkatsoft.com/xml-samples/bookstore.xml
# http://www.chilkatsoft.com/xml-samples/nutrition.xml
# http://www.chilkatsoft.com/xml-samples/pigs.xml
# http://www.chilkatsoft.com/xml-samples/plants.xml
# http://www.chilkatsoft.com/xml-samples/japanese.xml
# http://www.chilkatsoft.com/xml-samples/hamlet.xml
    
# The content of any node can be 128-bit AES encrypted. compressed.  
# a string that is the base64-encoded representation of the encrypted data.
xml = Chilkat::CkXml.new()
xml.put_Tag("encryptionExample")
xml.put_Content("This content is to be encrypted")
xml.EncryptContent("secretPassword")

# Print the XML document
strXml = Chilkat::CkString.new()
xml.GetXml(strXml)
printf "%s\n",strXml.getString()
# Prints
# <encryptionExample>0ZPEO/Cx1AzOupzei6GY/boc+P1ll9+lvCm+w1pE4mE=
# </encryptionExample>

# To restore the node's content, call DecryptContent:
# The password must match.
xml.DecryptContent("secretPassword")
xml.GetXml(strXml)
printf "%s\n",strXml.getString()
# Prints
# <encryptionExample>This content is to be encrypted</encryptionExample>






 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.