File tree 2 files changed +30
-3
lines changed
2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 1
- using System . Xml ;
1
+ using System ;
2
+ using System . Xml ;
2
3
3
4
namespace SPHDecode . Implementations
4
5
{
@@ -26,5 +27,31 @@ public static bool IsValidXML(string value)
26
27
return false ;
27
28
}
28
29
}
30
+
31
+ public static byte [ ] removeNullByte ( byte [ ] data )
32
+ {
33
+ if ( data [ data . Length - 1 ] . Equals ( 0 ) )
34
+ {
35
+ byte [ ] tmp = new byte [ data . Length - 1 ] ;
36
+ Array . Copy ( data , tmp , data . Length - 1 ) ;
37
+
38
+ return tmp ;
39
+ }
40
+
41
+ return data ;
42
+ }
43
+
44
+ public static byte [ ] addNullByte ( byte [ ] data )
45
+ {
46
+ if ( data [ data . Length - 1 ] . Equals ( 0 ) . Equals ( false ) )
47
+ {
48
+ byte [ ] tmp = data ;
49
+ Array . Resize ( ref tmp , tmp . Length + 1 ) ;
50
+
51
+ return tmp ;
52
+ }
53
+
54
+ return data ;
55
+ }
29
56
}
30
57
}
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ private void OndstFileDialogExecute()
72
72
private void OnencryptExecute ( )
73
73
{
74
74
byte [ ] orig = File . ReadAllBytes ( srcFile ) ;
75
- byte [ ] encode = Cryptography . Encrypt ( orig ) ;
75
+ byte [ ] encode = Cryptography . Encrypt ( util . addNullByte ( orig ) ) ;
76
76
77
77
if ( Object . Equals ( encode , null ) . Equals ( false ) )
78
78
{
@@ -84,7 +84,7 @@ private void OnencryptExecute()
84
84
private void OndecryptExecute ( )
85
85
{
86
86
byte [ ] orig = File . ReadAllBytes ( srcFile ) ;
87
- byte [ ] decode = Cryptography . Decrypt ( orig ) ;
87
+ byte [ ] decode = util . removeNullByte ( Cryptography . Decrypt ( orig ) ) ;
88
88
89
89
if ( Object . Equals ( decode , null ) . Equals ( false ) )
90
90
{
You can’t perform that action at this time.
0 commit comments