DEA64encrypt (String function): Difference between revisions
m (Added key length) |
m (add many details and example) |
||
Line 1: | Line 1: | ||
{{Template:String:DEA64encrypt subtitle}} | {{Template:String:DEA64encrypt subtitle}} | ||
This method applies the DEA (Data Encryption Algorithm) using a 64-bit symmetric key to encrypt each 64-bit block of input text. For more details about how the algorithm works, see [https://en.wikipedia.org/wiki/Data_Encryption_Standard Data Encryption Standard]. | |||
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:dea64encrypt(%key):dea64decrypt(%key) eq %string | |||
</p> | |||
You can use <var>RC4decrypt</var> to "document" that you are decrypting, and | |||
use <var>RC4encrypt</var> to "document" that you are enrypting. In the remainder of this article, you can use <var>RC4decrypt</var> and <var>RC4encrypt</var> interchangeably. | |||
==Syntax== | ==Syntax== | ||
{{Template:String:DEA64encrypt syntax}} | {{Template:String:DEA64encrypt syntax}} | ||
{{Template:String:DEA64decrypt syntax}} | |||
===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, | <td>An 8-byte (only) string variable whose value is used to encrypt or decrypt the method object, <var class="term">string</var>.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | |||
<li>The <var>DEA64encrypt</var> and <var>DEA64decrypt</var> functions are available as of <var class="product">Model 204</var> 7.6. </li> | |||
</ul> | |||
==Examples== | ==Examples== | ||
In the following example, the output string from the <var>DEA64encrypt</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 longstring | |||
%string = 'onetwothreefour0onetwothreefour0' | |||
%key = '12345678' | |||
%ls = %string:dea64encrypt(%key) | |||
[[PrintText statement|printText]] {~} is {%ls:stringTohex} | |||
printText {~} is: {%ls:rc4decrypt(%key)} | |||
end | |||
</p> | |||
The result is: | |||
<p class="output">%ls:stringTohex is: A54138C10468C061567574F88567E221A54138C10468C061567574F88567E221 | |||
%ls:dea64decrypt(%key) is: onetwothreefour0onetwothreefour0 | |||
</p> | |||
==See also== | ==See also== | ||
<ul> | |||
<li><var>[[DEA128encrypt (String function)|DEA128encrypt]]</var> </li> | |||
<li><var>[[DEA256encrypt (String function)|DEA256encrypt]]</var> </li> | |||
</ul> | |||
{{Template:String:DEA64encrypt footer}} | {{Template:String:DEA64encrypt footer}} |
Revision as of 22:41, 8 March 2016
DEA 64-bit key decryption (String class)
This method applies the DEA (Data Encryption Algorithm) using a 64-bit symmetric key to encrypt each 64-bit block of input text. For more details about how the algorithm works, see Data Encryption Standard.
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:dea64encrypt(%key):dea64decrypt(%key) eq %string
You can use RC4decrypt to "document" that you are decrypting, and use RC4encrypt to "document" that you are enrypting. In the remainder of this article, you can use RC4decrypt and RC4encrypt interchangeably.
Syntax
%outString = string:DEA64encrypt( key) Throws UnsupportedCrypto, InvalidCryptoKey, InvalidCryptoData
%outString = string:DEA64decrypt( key) Throws UnsupportedCrypto, InvalidCryptoKey, InvalidCryptoData
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 | An 8-byte (only) string variable whose value is used to encrypt or decrypt the method object, string. |
Usage notes
- The DEA64encrypt and DEA64decrypt functions are available as of Model 204 7.6.
Examples
In the following example, the output string from the DEA64encrypt 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 longstring %string = 'onetwothreefour0onetwothreefour0' %key = '12345678' %ls = %string:dea64encrypt(%key) printText {~} is {%ls:stringTohex} printText {~} is: {%ls:rc4decrypt(%key)} end
The result is:
%ls:stringTohex is: A54138C10468C061567574F88567E221A54138C10468C061567574F88567E221 %ls:dea64decrypt(%key) is: onetwothreefour0onetwothreefour0