wiki.sine.space | sinespace

Difference between revisions of "Scripting/SString"

From wiki.sine.space
Jump to: navigation, search
Line 2: Line 2:
  
 
==Members==
 
==Members==
{{ScriptFunction|string|MD5|(string input);|Calculates the MD5Sum of input and returns the result as a hexadecimal string|5 = local inputString = "An input string with data to hash."<br>local md5Hash = Space.String.MD5(inputString)<br>Space.Log(md5Hash)<br>-- prints "304f8dd8835d5fbd159299f7d07653fd"}}
+
{{ScriptFunction|string|MD5|(string input);|Calculates the MD5Sum of input and returns the result as a hexadecimal string|5 = local inputString = "An input string with data to hash."<br>local md5Hash = '''Space.String.MD5'''(inputString)<br>Space.Log(md5Hash)<br''>-- prints "304f8dd8835d5fbd159299f7d07653fd"''}}
  
{{ScriptFunction|string|Base64Encode|(string input);|Converts input to Base64 and returns the result|5 = local inputString = "input to encode"<br>local baseEncodeStr = Space.String.Base64Encode(inputString)<br>Space.Log(baseEncodeStr)<br>-- prints "aW5wdXQgdG8gZW5jb2Rl"}}
+
{{ScriptFunction|string|Base64Encode|(string input);|Converts input to Base64 and returns the result|5 = local inputString = "input to encode"<br>local baseEncodeStr = '''Space.String.Base64Encode'''(inputString)<br>Space.Log(baseEncodeStr)<br>''-- prints "aW5wdXQgdG8gZW5jb2Rl"''}}
  
{{ScriptFunction|string|Base64Encode|(byte[] input);|Converts input to Base64 and returns the result|5 = local inputByteArray = {105, 110, 112, 117, 116, 32, 116, 111, 32, 101, 110, 99, 111, 100, 101}<br>local baseEncodeByte = Space.String.Base64Encode(inputByteArray)<br>Space.Log(baseEncodeByte)<br>-- prints "aW5wdXQgdG8gZW5jb2Rl"}}
+
{{ScriptFunction|string|Base64Encode|(byte[] input);|Converts input to Base64 and returns the result|5 = local inputByteArray = {105, 110, 112, 117, 116, 32, 116, 111, 32, 101, 110, 99, 111, 100, 101}<br>local baseEncodeByte = '''Space.String.Base64Encode'''(inputByteArray)<br>Space.Log(baseEncodeByte)<br>''-- prints "aW5wdXQgdG8gZW5jb2Rl"''}}
  
{{ScriptFunction|string|Base64Decode|(string input);|Converts input from Base64 and returns the result|5 = local inputBase64String = "aW5wdXQgdG8gZW5jb2Rl"<br>local baseDecodedStr = Space.String.Base64Decode(inputBase64String)<br>Space.Log(baseDecodedStr)<br>-- prints "input to encode"}}
+
{{ScriptFunction|string|Base64Decode|(string input);|Converts input from Base64 and returns the result|5 = local inputBase64String = "aW5wdXQgdG8gZW5jb2Rl"<br>local baseDecodedStr = '''Space.String.Base64Decode'''(inputBase64String)<br>Space.Log(baseDecodedStr)<br>''-- prints "input to encode"''}}
  
{{ScriptFunction|byte|GetBytes[]|(string input);|Converts input to bytes using UTF8 encoding|5 = local inputString = "some data string"<br>local stringAsByteArray = Space.String.GetBytes(inputString)<br>Space.Log(stringAsByteArray[1])<br>-- prints "115"}}
+
{{ScriptFunction|byte|GetBytes[]|(string input);|Converts input to bytes using UTF8 encoding|5 = local inputString = "some data string"<br>local stringAsByteArray = '''Space.String.GetBytes'''(inputString)<br>Space.Log(stringAsByteArray[1])<br>''-- prints "115"''}}
  
{{ScriptFunction|string|GetString|(byte[] input);|Converts input to a UTF8 string|5 = local inputByteArray = {115, 111, 109, 101, 32, 100, 97, 116, 97, 32, 115, 116, 114, 105, 110, 103}<br>local ByteArrayAsString = Space.String.GetString(inputByteArray)<br>Space.Log(ByteArrayAsString)<br>-- prints "some data string"}}
+
{{ScriptFunction|string|GetString|(byte[] input);|Converts input to a UTF8 string|5 = local inputByteArray = {115, 111, 109, 101, 32, 100, 97, 116, 97, 32, 115, 116, 114, 105, 110, 103}<br>local ByteArrayAsString = '''Space.String.GetString'''(inputByteArray)<br>Space.Log(ByteArrayAsString)<br>''-- prints "some data string"''}}
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 19:02, 20 April 2017

The SHost class represents the scripting runtime.

Members

MD5

string MD5 (string input);

Calculates the MD5Sum of input and returns the result as a hexadecimal string

local inputString = "An input string with data to hash."
local md5Hash = Space.String.MD5(inputString)
Space.Log(md5Hash)<br>-- prints "304f8dd8835d5fbd159299f7d07653fd"


Base64Encode

string Base64Encode (string input);

Converts input to Base64 and returns the result

local inputString = "input to encode"
local baseEncodeStr = Space.String.Base64Encode(inputString)
Space.Log(baseEncodeStr)
-- prints "aW5wdXQgdG8gZW5jb2Rl"


Base64Encode

string Base64Encode (byte[] input);

Converts input to Base64 and returns the result

local inputByteArray = {105, 110, 112, 117, 116, 32, 116, 111, 32, 101, 110, 99, 111, 100, 101}
local baseEncodeByte = Space.String.Base64Encode(inputByteArray)
Space.Log(baseEncodeByte)
-- prints "aW5wdXQgdG8gZW5jb2Rl"


Base64Decode

string Base64Decode (string input);

Converts input from Base64 and returns the result

local inputBase64String = "aW5wdXQgdG8gZW5jb2Rl"
local baseDecodedStr = Space.String.Base64Decode(inputBase64String)
Space.Log(baseDecodedStr)
-- prints "input to encode"


GetBytes[]

byte GetBytes[] (string input);

Converts input to bytes using UTF8 encoding

local inputString = "some data string"
local stringAsByteArray = Space.String.GetBytes(inputString)
Space.Log(stringAsByteArray[1])
-- prints "115"


GetString

string GetString (byte[] input);

Converts input to a UTF8 string

local inputByteArray = {115, 111, 109, 101, 32, 100, 97, 116, 97, 32, 115, 116, 114, 105, 110, 103}
local ByteArrayAsString = Space.String.GetString(inputByteArray)
Space.Log(ByteArrayAsString)
-- prints "some data string"