Added 2 new charsets in randomstring function.

This commit is contained in:
Itamai
2019-07-19 19:19:11 +02:00
parent 476eac42db
commit aa8cb268b0
2 changed files with 9 additions and 2 deletions
@@ -115,7 +115,7 @@ namespace OpenBullet.Pages.StackerBlocks
{ "Constant", "This will just return anything written in the input string and store it in a variable, after possibly replacing all the input variables.\nUse this to chain constants and variables together." }, { "Constant", "This will just return anything written in the input string and store it in a variable, after possibly replacing all the input variables.\nUse this to chain constants and variables together." },
{ "Hash", "The input string will be hashed with the selected function. Remember you can chain variables if you need a salt." }, { "Hash", "The input string will be hashed with the selected function. Remember you can chain variables if you need a salt." },
{ "HMAC", "" }, { "HMAC", "" },
{ "RandomString", "?l = Lowercase, ?u = Uppercase, ?d = Digit, ?s = Symbol, ?h = Hex (Lowercase), ?a = Any"}, { "RandomString", "?l = Lowercase, ?u = Uppercase, ?d = Digit, ?s = Symbol, ?h = Hex (Lowercase), ?m = Upper + Digits, ?i = Lower + Upper + Digits, ?a = Any"},
{ "Translate", "Format like headers (this: that), one per line." }, { "Translate", "Format like headers (this: that), one per line." },
{ "Compute", "Calculates the value of a math expression, for example (6+3)*5 will return 45." }, { "Compute", "Calculates the value of a math expression, for example (6+3)*5 will return 45." },
{ "RSA", "Thanks to TheLittleTrain17 for this implementation" }, { "RSA", "Thanks to TheLittleTrain17 for this implementation" },
+8 -1
View File
@@ -614,13 +614,15 @@ namespace RuriLib
break; break;
case Function.RandomString: case Function.RandomString:
var reserved = new string[] { "?l", "?u", "?d", "?s", "?h", "?a" }; var reserved = new string[] { "?l", "?u", "?d", "?s", "?h", "?a", "?i", "?m" };
var lowercase = "abcdefghijklmnopqrstuvwxyz"; var lowercase = "abcdefghijklmnopqrstuvwxyz";
var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var digits = "0123456789"; var digits = "0123456789";
var symbols = "\\!\"£$%&/()=?^'{}[]@#,;.:-_*+"; var symbols = "\\!\"£$%&/()=?^'{}[]@#,;.:-_*+";
var hex = digits + "abcdef"; var hex = digits + "abcdef";
var allchars = lowercase + uppercase + digits + symbols; var allchars = lowercase + uppercase + digits + symbols;
var meinchars = uppercase + digits;
var itachars = lowercase + uppercase + digits;
outputString = localInputString; outputString = localInputString;
while (reserved.Any(r => outputString.Contains(r))){ while (reserved.Any(r => outputString.Contains(r))){
@@ -636,6 +638,11 @@ namespace RuriLib
outputString = ReplaceFirst(outputString, "?h", hex[data.rand.Next(0, hex.Length)].ToString()); outputString = ReplaceFirst(outputString, "?h", hex[data.rand.Next(0, hex.Length)].ToString());
else if (outputString.Contains("?a")) else if (outputString.Contains("?a"))
outputString = ReplaceFirst(outputString, "?a", allchars[data.rand.Next(0, allchars.Length)].ToString()); outputString = ReplaceFirst(outputString, "?a", allchars[data.rand.Next(0, allchars.Length)].ToString());
else if (outputString.Contains("?i"))
outputString = ReplaceFirst(outputString, "?i", itachars[data.rand.Next(0, itachars.Length)].ToString());
else if (outputString.Contains("?m"))
outputString = ReplaceFirst(outputString, "?m", meinchars[data.rand.Next(0, meinchars.Length)].ToString());
} }
break; break;