Browse Source

Implement `ungroupBytes`

DricomDragon 5 năm trước cách đây
mục cha
commit
5af84992f5
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      tp/rsa/main.hs

+ 4 - 0
tp/rsa/main.hs

@@ -39,3 +39,7 @@ groupBytes = subgroupBytes 1 0
 subgroupBytes::Int -> Int -> Message -> Int
 subgroupBytes _ acc [] = acc
 subgroupBytes pow acc (c:msg) = subgroupBytes (pow * 256) (acc + c * pow) msg
+
+ungroupBytes::Int -> Message
+ungroupBytes 0 = []
+ungroupBytes n = (mod n 256):ungroupBytes (div n 256)