DEA64decrypt and DEA64encrypt (String functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{Template:String:DEA64decrypt and DEA64encrypt subtitle}} <var>DEA64decrypt</var> and <var>DEA64encrypt</var> are synonyms for the String class function that applies the...")
 
m (→‎See also: add templates)
 
(6 intermediate revisions by the same user not shown)
Line 8: Line 8:
<p class="code">[[Assert statement|assert]] %string:dea64encrypt(%key):dea64decrypt(%key) eq %string
<p class="code">[[Assert statement|assert]] %string:dea64encrypt(%key):dea64decrypt(%key) eq %string
</p>
</p>
You can use <var>RC4decrypt</var> to "document" that you are decrypting, and
You can use <var>DEA64decrypt</var> to "document" that you are decrypting, and
use <var>RC4encrypt</var> to "document" that you are enrypting. You can use <var>RC4decrypt</var> and <var>RC4encrypt</var> interchangeably on the rest of this page.
use <var>DEA64encrypt</var> to "document" that you are encrypting. You can use <var>DEA64decrypt</var> and <var>DEA64encrypt</var> interchangeably on the rest of this page.


==Syntax==
==Syntax==
Line 40: Line 40:
%ls is longstring     
%ls is longstring     
%string is longstring
%string is longstring
%key is longstring
%key is string len 8
%string = 'onetwothreefour0onetwothreefour0'
%string = 'onetwothreefour0onetwothreefour0'
%key = '12345678'
%key = '12345678'
Line 46: Line 46:
%ls = %string:dea64encrypt(%key)
%ls = %string:dea64encrypt(%key)
[[PrintText statement|printText]] {~} is {%ls:stringTohex}
[[PrintText statement|printText]] {~} is {%ls:stringTohex}
printText {~} is: {%ls:rc4decrypt(%key)}
printText {~} is: {%ls:dea64decrypt(%key)}
end
end
</p>
</p>
Line 56: Line 56:
==See also==
==See also==
<ul>
<ul>
<li><var>[[DEA128encrypt (String function)|DEA128encrypt]]</var> </li>
<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>[[DEA256encrypt (String function)|DEA256encrypt]]</var> </li>
<li><var>[[SHA256digest (String function)|SHA256digest]]</var> </li>
</ul></li>
</ul>
</ul>


{{Template:String:DEA64decrypt and DEA64encrypt footer}}
{{Template:String:DEA64decrypt and DEA64encrypt footer}}

Latest revision as of 20:48, 16 March 2016

DEA64 encryption or decryption (String class)

[Introduced in Model 204 7.6]


DEA64decrypt and DEA64encrypt 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. 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 DEA64decrypt to "document" that you are decrypting, and use DEA64encrypt to "document" that you are encrypting. You can use DEA64decrypt and DEA64encrypt interchangeably on the rest of this page.

Syntax

%outString = string:DEA64decrypt( key) Throws UnsupportedCrypto, InvalidCryptoKey, InvalidCryptoData

%outString = string:DEA64encrypt( 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

  • You are not prevented from creating confusion by encrypting with DEA64decrypt and decrypting with DEA64encrypt.
  • The DEA64decrypt and DEA64encrypt 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 string len 8 %string = 'onetwothreefour0onetwothreefour0' %key = '12345678' %ls = %string:dea64encrypt(%key) printText {~} is {%ls:stringTohex} printText {~} is: {%ls:dea64decrypt(%key)} end

The result is:

%ls:stringTohex is: A54138C10468C061567574F88567E221A54138C10468C061567574F88567E221 %ls:dea64decrypt(%key) is: onetwothreefour0onetwothreefour0

See also