• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonbitlang / x / 301

10 Dec 2024 06:19AM UTC coverage: 85.204% (-2.6%) from 87.841%
301

Pull #78

github

web-flow
Merge b830031f4 into 91f0fdf48
Pull Request #78: feat: new package encoding

105 of 161 new or added lines in 3 files covered. (65.22%)

124 existing lines in 29 files now uncovered.

1169 of 1372 relevant lines covered (85.2%)

434.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/crypto/sha224.mbt
1
// Copyright 2024 International Digital Economy Academy
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
///|
16
pub fn sha224(data : Bytes) -> Bytes {
17
  let ctx = Sha256Context::new(
9✔
18
    reg=[
19
      0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7,
20
      0xbefa4fa4,
21
    ],
22
  )
23
  let _ = ctx.update(data)
24
  arr_u32_to_u8be(ctx.sha256_compute().iter().take(7), 224)
25
}
26

27
///|
28
pub fn sha224_from_iter(data : Iter[Byte]) -> Bytes {
UNCOV
29
  let ctx = Sha256Context::new(
×
30
    reg=[
31
      0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7,
32
      0xbefa4fa4,
33
    ],
34
  )
35
  let _ = ctx.update_from_iter(data)
36
  arr_u32_to_u8be(ctx.sha256_compute().iter().take(7), 224)
37
}
38

39
test {
40
  // Sha224
41
  assert_eq!(
42
    bytes_to_hex_string(sha224(b"\x61\x62\x63")),
43
    "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7",
44
  )
45
  assert_eq!(
46
    bytes_to_hex_string(
47
      sha224(
48
        b"\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64\x61\x62\x63\x64",
49
      ),
50
    ),
51
    "fffd3b5e90c6fc3cb77c3d04b1f7660b16a426ef6655384e8486ae1f",
52
  )
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc