ARSA Language  2.8
(Encryption, GPU and Web 3.0)
string.h File Reference

Go to the source code of this file.

Classes

class  string
 

Detailed Description

ARSA Language, String, Encryption and Compression operations:
Example:

// normal string using double quote in ascii
set( $str, "Hello World" )
// \"..."\ is power quote in ascii:
// special code with \t \n \r \0 using power quote and string.replacewhitespace()
set($str, string.replacewhitespace(\"\the\tl\nl\ro"\) )
// limitation: user cannot use tab directly in string but user can use \t with power quote and string.replacewhitespace() like this:
set($tab, string.replacewhitespace(\"6210612724\t77.55"\)) // result is 6210612724 77.55
// special string using -> backslash cover start and end quote.
set( $xml, \"<?xml version="1.0" encoding="UTF-8"?> <note> <to>Tove</to> <from test="hello world">Jani</from> <heading>Reminder</heading><body>Don't forget me this weekend!</body></note>"\ )
// json example 1.
set($json_str1, \"{"menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] } }"\)
// json example 2.
set($json_str2, \" ,"glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } }"\)
// curl string command using power quote in ascii example:
set($id, curl(\"-X POST -k -d "client_id=hh7ec2.apps.googleusercontent.com&scope=https://www.googleapis.com/auth/drive.file" https://oauth2.googleapis.com/device/code"\) )
set($str, "hello - how are you?")
alog( string.empty($str) ) // result: false
alog( string.empty("") ) // result: true
alog( string.size($str) ) // result: 20
alog( string.replacewhitespace(\"\thello\thow \nare you?"\) ) // result: " hello how are you?"
alog( string.cat($str," [end]") ) // result: "hello - how are you? [end]"
alog( string.erase($str,8) ) // result: "hello - ow are you?"
alog( string.sub($str,8, 3) ) // result: "how"
alog( string.replace($str,"you", "me") ) // result: "hello - how are me?"
alog( string.charat($str,8) ) // result: h
alog( string.upper($str) ) // result: "HELLO - HOW ARE YOU?"
alog( string.lower($str) ) // result: "hello - how are you?"
alog( string.find($str,"h") ) // result: 0
alog( string.findlast($str,"h") ) // result: 8
alog( string.findclearfirst($str,"h") ) // result: "ello - how are you?"
alog( string.findclearlast($str,"?") ) // result: "hello - how are you"
alog( string.addprefix($str,"john: ") ) // result: "john: hello - how are you?"
alog( string.addsuffix($str," [end]") ) // result: "hello - how are you? [end]"
alog( string.tokn($str,2) ) // result: "how"
alog( string.tokn($str,3) ) // result: "are"
alog( string.tokn($str,4) ) // result: "you?"
//================================
// advanced
//================================
// base64 encode decode
alog( string.base64encode($str) ) // result: "aGVsbG8gLSBob3cgYXJlIHlvdT8="
alog( string.base64decode("aGVsbG8gLSBob3cgYXJlIHlvdT8=") ) // result: "hello - how are you?"
// url encode decode
alog( string.urlencode($str) ) // result: "hello+-+how+are+you%3f"
alog( string.urldecode("hello+-+how+are+you%3f") ) // result: "hello - how are you?"
// binary encode decode
alog( string.binaryencode($str) ) // result: "0110100001100101011011000110110001101111001000000010110100100000011010000110111101110111001000000110000101110010011001010010000001111001011011110111010100111111"
alog( string.binarydecode("0110100001100101011011000110110001101111001000000010110100100000011010000110111101110111001000000110000101110010011001010010000001111001011011110111010100111111") ) // result: "hello - how are you?"
// decimal encode decode
alog( string.decencode($str) ) // result: 104 101 108 108 111 32 45 32 104 111 119 32 97 114 101 32 121 111 117 63
alog( string.decdecode("104 101 108 108 111 32 45 32 104 111 119 32 97 114 101 32 121 111 117 63") ) // result: "hello - how are you?"
// heximal encode decode
alog( string.hexencode($str) ) // result: 68656c6c6f202d20686f772061726520796f753f
alog( string.hexdecode("68656c6c6f202d20686f772061726520796f753f") ) // result: "hello - how are you?"
// compression uncompression
string.tofile( "a.zip", string.compress($str), false, ascii ) // a.zip, ascii flag is save as binary file.
alog( string.uncompress(ftostring("a.zip", ascii)) ) // result: "hello - how are you?" , ascii flag is read as binary file.
// md5, sha256, crc32
alog( string.md5($str) ) // result: aea36ff47f10470c66746aeda9fa0d18
alog( string.sha256($str) ) // result: 08ddca8914dd34e00b708f18fcf632f161b6cfbe85c230e971cc167fc267f8b3
alog( string.crc32($str) ) // result: 3787c4f1
// encryption decryption
string.tofile( "b.zip", string.encryption($str, "password"), false, ascii ) // result: b.zip
alog( string.decryption(ftostring("b.zip", ascii), "password") ) // result: "hello - how are you?"
// encryption decryption with random password
set($random_pass, random_string_custom(10, "abcdefghijklmnopqrstuvwxyz") ) // 10 char length random password from string
alog($random_pass) // show password
string.tofile( "c.zip", string.encryption($str, $random_pass), false, ascii ) // result: c.zip
alog( string.decryption(ftostring("c.zip", ascii), $random_pass) ) // result: "hello - how are you?"
// zip unzip with crc32 checksum and random password
set($dzip, "d.zip" ) // zip name
set($alisname, "dummy" ) // just an alias name
string.tofile( $dzip, string.zip($str, $alisname, $random_pass), false, ascii ) // d.zip, ascii flag is save as binary file.
faddzip($dzip, $random_pass) // adding zipfile to filesystem
alog( ftostring(dummy.txt, ascii) ) // read alias name from zipfile in filesystem
alog(string.crc32(ftostring(dummy.txt, ascii))) // result: 3787c4f1
fremove($dzip) // remove zipfile from filesystem
alog(string.crc32(string.unzip(ftostring($dzip,ascii), $alisname, $random_pass))) // result: 3787c4f1
alog( string.unzip(ftostring($dzip,ascii), $alisname, $random_pass)) // result: "hello - how are you?"

Compression Level 9 and CRC32 Checksum Report:

start...compress level: 9
openfile...core-for-system-modules.jar size: 1.367 mbs.
checksum crc32...603040bf
compress...
compress used time: 0.224 second. size: 1.148 mbs.
uncompress...
uncompress used time: 0.175 second. size: 1.367 mbs.
passed [OK]
openfile...avcodec-56.dll size: 8.906 mbs.
checksum crc32...7a470602
compress...
compress used time: 1.661 second. size: 4.173 mbs.
uncompress...
uncompress used time: 1.780 second. size: 8.906 mbs.
passed [OK]
openfile...bundletool-all-1.7.0.jar size: 26.714 mbs.
checksum crc32...cbd6e8ef
compress...
compress used time: 12.339 second. size: 24.669 mbs.
uncompress...
uncompress used time: 12.396 second. size: 26.714 mbs.
passed [OK]
end.

Definition in file string.h.