DEA128CBCdecrypt and DEA128CBCencrypt (String functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{Template:String:DEA128CBCdecrypt and DEA128CBCencrypt subtitle}} This page is under construction. ==Syntax== {{Template:String:DEA128CBCdecrypt syntax}} {{Template:Str...")
 
m (→‎See also: add templates)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:String:DEA128CBCdecrypt and DEA128CBCencrypt subtitle}}
{{Template:String:DEA128CBCdecrypt and DEA128CBCencrypt subtitle}}


This page is [[under construction]].
<var>DEA128CBCdecrypt</var> and <var>DEA128CBCencrypt</var> are synonyms for the [[String class]] function that applies the DEA (Data Encryption Algorithm) using a 64-bit symmetric key to decrypt or encrypt each 64-bit block of input text. CBC (Cipher Block Chaining) refers to a randomizing tactic whereby the result of applying the DEA cipher to a 64-bit block is combined with the next block before the next block's encryption; and so on for each subsequent block. An initialization vector is used in the first block to make its encryption unique.
 
For more details about how the algorithm works, see [https://en.wikipedia.org/wiki/Data_Encryption_Standard Data Encryption Standard] and [https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher Block Chaining (CBC) Cipher Block Chaining (CBC)].
 
The length of the returned string is the same as that of the object string.
 
DEA is a two-way cipher, so encrypting a string with a key and then decrypting the result of that encryption with the same key produces the original string. That is, the following assertion should <b><i>always</i></b> hold:
<p class="code">[[Assert statement|assert]] %string:dea128cbcencrypt(%key):dea128cbcdecrypt(%key) eq %string
</p>
You can use <var>DEA128CBCdecrypt</var> to "document" that you are decrypting, and
use <var>DEA128CBCencrypt</var> to "document" that you are encrypting. You can use <var>DEA128CBCdecrypt</var> and <var>DEA128CBCencrypt</var> interchangeably on the rest of this page.


==Syntax==
==Syntax==
Line 9: Line 19:
===Syntax terms===
===Syntax terms===
<table>
<table>
<tr><th>%outString</th><td>string</td></tr>
<tr><th>%outString</th>
<td>A string variable to receive the encrypted or decrypted method object <var class="term">string</var>. Its length is the same as <var class="term">string</var>.</td></tr>


<tr><th>string</th>
<tr><th>string</th>
<td>string</td></tr>
<td>The string to which the method is applied. <var class="term">string</var> must be a multiple of eight bytes in length; its  maximum is 32768 bytes. It may be null.</td></tr>


<tr><th>key</th>
<tr><th>key</th>
<td>string, length 16</td></tr>
<td>A 16-byte (only) string variable whose value is used to encrypt or decrypt the method object, <var class="term">string</var>.</td></tr>


<tr><th>initVector</th>
<tr><th>initVector</th>
<td>string, length 8
<td>An 8-byte string that is used to randomize the encryption.
</td></tr>
The initialization vector is used to ensure distinct ciphertexts are produced even when the same plaintext is encrypted multiple times independently with the same key.</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<li>You are <b><i>not</i></b> prevented from creating confusion by encrypting with <var>DEA128CBCdecrypt</var> and decrypting with <var>DEA128CBCencrypt</var>. </li>
<li>The <var>DEA128CBCdecrypt</var> and <var>DEA128CBCencrypt</var> functions are available as of <var class="product">Model&nbsp;204</var> 7.6. </li>
</ul>


==Examples==
==Examples==
In the following example, the output string from the <var>DEA128CBCencrypt</var> method is converted to hex using the <var>[[StringToHex (String function)|StringToHex]]</var> function to reveal its non-displayable characters, then decrypted to return the original input string:
<p class="code">b                   
%ls is longstring   
%string is longstring
%key is string len 16
%iv is string len 8
%string = 'onetwothreefour0onetwothreefour0'
%key = '1234567816161616'
%iv = 'abcdefgh'
%ls = %string:dea128cbcEncrypt(%key, %iv)
[[PrintText statement|printText]] {~} is {%ls:stringTohex}
printText {~} is: {%ls:dea128cbcDecrypt(%key, %iv)}
end
</p>
The result is:
<p class="output">%ls:stringTohex is: 31C96E0DC22B9503D8CEAE6BCCF569C5A669BD6BF90F9A8205F544CD647926F9
%ls:dea128cbcDecrypt(%key, %iv) is: onetwothreefour0onetwothreefour0
</p>


==See also==
==See also==
<ul>
<li>Additional DEA methods:
<ul>
{{Template:DEA crypto methods}}
</ul></li>
<li>Additional two-way ciphers:
<ul>
{{Template:AES crypto methods}}
<li>[[RC4decrypt and RC4encrypt (String functions)]]</li>
</ul></li>
<li><var>String</var> one-way ciphers:
<ul>
<li><var>[[MD5digest (String function)|MD5digest]]</var> </li>
<li><var>[[SHAdigest (String function)|SHAdigest]]</var> </li>
<li><var>[[SHA224digest (String function)|SHA224digest]]</var> </li>
<li><var>[[SHA256digest (String function)|SHA256digest]]</var> </li>
</ul></li>
</ul>
{{Template:String:DEA128CBCdecrypt and DEA128CBCencrypt footer}}
{{Template:String:DEA128CBCdecrypt and DEA128CBCencrypt footer}}

Latest revision as of 20:53, 16 March 2016

DEA128CBC encryption or decryption (String class)

[Introduced in Model 204 7.6]


DEA128CBCdecrypt and DEA128CBCencrypt are synonyms for the String class function that applies the DEA (Data Encryption Algorithm) using a 64-bit symmetric key to decrypt or encrypt each 64-bit block of input text. CBC (Cipher Block Chaining) refers to a randomizing tactic whereby the result of applying the DEA cipher to a 64-bit block is combined with the next block before the next block's encryption; and so on for each subsequent block. An initialization vector is used in the first block to make its encryption unique.

For more details about how the algorithm works, see Data Encryption Standard and Block Chaining (CBC) Cipher Block Chaining (CBC).

The length of the returned string is the same as that of the object string.

DEA is a two-way cipher, so encrypting a string with a key and then decrypting the result of that encryption with the same key produces the original string. That is, the following assertion should always hold:

assert %string:dea128cbcencrypt(%key):dea128cbcdecrypt(%key) eq %string

You can use DEA128CBCdecrypt to "document" that you are decrypting, and use DEA128CBCencrypt to "document" that you are encrypting. You can use DEA128CBCdecrypt and DEA128CBCencrypt interchangeably on the rest of this page.

Syntax

%outString = string:DEA128CBCdecrypt( key, initVector) Throws UnsupportedCrypto, InvalidCryptoKey, InvalidCryptoData, InvalidCryptoInitVector

%outString = string:DEA128CBCencrypt( key, initVector) Throws UnsupportedCrypto, InvalidCryptoKey, InvalidCryptoData, InvalidCryptoInitVector

Syntax terms

%outString A string variable to receive the encrypted or decrypted method object string. Its length is the same as string.
string The string to which the method is applied. string must be a multiple of eight bytes in length; its maximum is 32768 bytes. It may be null.
key A 16-byte (only) string variable whose value is used to encrypt or decrypt the method object, string.
initVector An 8-byte string that is used to randomize the encryption. The initialization vector is used to ensure distinct ciphertexts are produced even when the same plaintext is encrypted multiple times independently with the same key.

Usage notes

  • You are not prevented from creating confusion by encrypting with DEA128CBCdecrypt and decrypting with DEA128CBCencrypt.
  • The DEA128CBCdecrypt and DEA128CBCencrypt functions are available as of Model 204 7.6.

Examples

In the following example, the output string from the DEA128CBCencrypt method is converted to hex using the StringToHex function to reveal its non-displayable characters, then decrypted to return the original input string:

b %ls is longstring %string is longstring %key is string len 16 %iv is string len 8 %string = 'onetwothreefour0onetwothreefour0' %key = '1234567816161616' %iv = 'abcdefgh' %ls = %string:dea128cbcEncrypt(%key, %iv) printText {~} is {%ls:stringTohex} printText {~} is: {%ls:dea128cbcDecrypt(%key, %iv)} end

The result is:

%ls:stringTohex is: 31C96E0DC22B9503D8CEAE6BCCF569C5A669BD6BF90F9A8205F544CD647926F9 %ls:dea128cbcDecrypt(%key, %iv) is: onetwothreefour0onetwothreefour0

See also