Skip to content

Commit

Permalink
Add base64 SYSCALLs (#1717)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang authored Jun 23, 2020
1 parent 2047892 commit 815180c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/neo/SmartContract/ApplicationEngine.Binary.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using Neo.VM.Types;
using static System.Convert;

namespace Neo.SmartContract
{
partial class ApplicationEngine
{
public static readonly InteropDescriptor System_Binary_Serialize = Register("System.Binary.Serialize", nameof(BinarySerialize), 0_00100000, TriggerType.All, CallFlags.None, true);
public static readonly InteropDescriptor System_Binary_Deserialize = Register("System.Binary.Deserialize", nameof(BinaryDeserialize), 0_00500000, TriggerType.All, CallFlags.None, true);
public static readonly InteropDescriptor System_Binary_Base64Encode = Register("System.Binary.Base64Encode", nameof(Base64Encode), 0_00100000, TriggerType.All, CallFlags.None, true);
public static readonly InteropDescriptor System_Binary_Base64Decode = Register("System.Binary.Base64Decode", nameof(Base64Decode), 0_00100000, TriggerType.All, CallFlags.None, true);

internal byte[] BinarySerialize(StackItem item)
{
Expand All @@ -16,5 +19,15 @@ internal StackItem BinaryDeserialize(byte[] data)
{
return BinarySerializer.Deserialize(data, MaxStackSize, MaxItemSize, ReferenceCounter);
}

internal string Base64Encode(byte[] data)
{
return ToBase64String(data);
}

internal byte[] Base64Decode(string s)
{
return FromBase64String(s);
}
}
}

0 comments on commit 815180c

Please sign in to comment.