Friday, December 31, 2010

jBase Infobasic Function ENCRYPT

The ENCRYPT function encrypts strings. see also DECRYPT

Command Syntax

ENCRYPT(string, key, method)

Syntax Elements

string => specifies the string for encryption.
key => is the value used to encrypt the string. Its use depends on method.
method => is a value, which indicates the encryption mechanism to use (See below):

The ENCRYPT and DECRYPT functions that are part of jBASE BASIC now support the following cipher methods (Defined in JBC.h)

JBASE_CRYPT_GENERAL General-purpose encryption scheme
JBASE_CRYPT_ROT13 Simple ROT13 algorithm. (Key not used)
JBASE_CRYPT_XOR11 XOR MOD11 algorithm. Uses the first character of a key as a seed value.
JBASE_CRYPT_RC2 RC2 algorithm
JBASE_CRYPT_DES DES algorithm
JBASE_CRYPT_3DES Three Key, Triple DES algorithm
JBASE_CRYPT_BLOWFISH Blowfish algorithm
JBASE_CRYPT_BASE64 (See below)
BASE64 is more of an encoding method rather than an encryption method. The reason for this is that the output of an encryption often results in a binary string, which allows the representation of binary data as a character string. Although not required the BASE64 operation is performed in addition to the primary algorithm. E.g. JBASE_CRYPT_RC2_BASE64

ENCRYPT with this method is the same as an ENCRYPT with method JBASE_CRYPT_RC2 followed by ENCRYPT with method JBASE_CRYPT_BASE64.

DECRYPT with this method is the same as a DECRYPT with method JBASE_CRYPT_BASE64 followed by DECRYPT with method JBASE_CRYPT_RC2.
JBASE_CRYPT_RC2_BASE64 RC2 algorithm
JBASE_CRYPT_DES_BASE64 DES algorithm
JBASE_CRYPT_3DES_BASE64 Triple DES algorithm
JBASE_CRYPT_BLOWFISH _BASE64 Blowfish algorithm

Example

INCLUDE JBC.h
X = DECRYPT(X, Ekey, JBASE_CRYPT_GENERAL)
IF DECRYPT("rknzcyr”,"", JBASE_CRYPT_ROT13) = "example" THEN
CRT "ROT13 ok"
END
IF ENCRYPT("g{ehvkm","9", JBASE_CRYPT_XOR11) = "example" THEN
CRT "XOR.MOD11 ok"
END
cipher = JBASE_CRYPT_BLOWFISH_BASE64
key = "Our Very Secret Key"
str = "String to encrypt"
enc = ENCRYPT( str, key, cipher )
CRT "Encrypted: ":enc
dec = DECRYPT( enc, key, cipher )
CRT "Decrypted: ":dec

Output

Encrypted: xuy6DXxUkD32spyfsKEvUtXrsjP7mC+R
Decrypted: String to encrypt

0 comments:

Post a Comment

 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems