Skip to content
lsl.devlsl.devLSL Dev

llSHA1String

function
Function syntax
string llSHA1String(
  1. string src// Source string to hash.
);
Returns
string
Energy
10

Returns a string of 40 hex characters representing the SHA-1 security hash of src.

Returns a string of 40 hex characters that is the SHA-1 security hash of src.

How to use
string result = llSHA1String("");

LSL strings are stored in the UTF-8 format.

There’s no way to input a zero-byte value into this function, nor any byte value from 128-255, therefore it’s currently broken for many purposes (like HMAC-SHA1). The reason is because LSL strings cannot have a unicode null character (U+0000) in them, and LSL has no escape code for the null character (many programming languages use \0 but LSL does not have this feature). llEscapeURL("%00") yields an empty string. As well, inside this function, each character with a Unicode integer value over U+0127 / 007F are dealt with in UTF-8 fashion: in the hex values, 0xC2 is appended to the byte value (hence 0x0080-0x00FF become 0xC280-0xC2FF inside the llSHA1String() routine). A JIRA has been filed for this.

Example 1
llSay(0, llSHA1String("Hello, Avatar!")); // returns 2E73318E547AF1B28CC0C96F95DDC9B1EE906B8D
Example 2
$ echo -n 'Hello, Avatar!' | openssl sha1
2E73318E547AF1B28CC0C96F95DDC9B1EE906B8D
  • SVN:1291 r98903 Trunk Initial introduction.
  • SVN:1298 r99021 Branch:OpenAL

Integration into OpenAL branch.

  • SHA-1 (script implementation)
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.