Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
This commit is contained in:
committed by
GitHub
parent
a07f84c8ec
commit
0bd52f8bd1
@ -5,46 +5,76 @@ challengeType: 5
|
||||
forumTopicId: 385328
|
||||
---
|
||||
|
||||
## Description
|
||||
# --description--
|
||||
|
||||
<section id='description'>
|
||||
<b><a href="https://en.wikipedia.org/wiki/SHA-256" target="_blank">SHA-256</a></b> is the recommended stronger alternative to <a href="https://rosettacode.org/wiki/SHA-1" target="_blank">SHA-1</a>.
|
||||
</section>
|
||||
**[SHA-256](https://en.wikipedia.org/wiki/SHA-256)** is the recommended stronger alternative to [SHA-1](https://rosettacode.org/wiki/SHA-1).
|
||||
|
||||
## Instructions
|
||||
# --instructions--
|
||||
|
||||
<section id='instructions'>
|
||||
Write a function that takes a string as a parameter and returns its SHA-256 digest.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
# --hints--
|
||||
|
||||
<section id='tests'>
|
||||
`SHA256` should be a function.
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>SHA256</code> should be a function.
|
||||
testString: assert(typeof SHA256 === 'function');
|
||||
- text: <code>SHA256("Rosetta code")</code> should return a string.
|
||||
testString: assert(typeof SHA256("Rosetta code") === 'string');
|
||||
- text: <code>SHA256("Rosetta code")</code> should return <code>"764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf"</code>.
|
||||
testString: assert.equal(SHA256("Rosetta code"), "764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf");
|
||||
- text: <code>SHA256("SHA-256 Hash")</code> should return <code>"bee8c0cabdcf8c7835f40217dd35a8b0dba9134520e633f1c57285f35ca7ee3e"</code>.
|
||||
testString: assert.equal(SHA256("SHA-256 Hash"), "bee8c0cabdcf8c7835f40217dd35a8b0dba9134520e633f1c57285f35ca7ee3e");
|
||||
- text: <code>SHA256("implementation")</code> should return <code>"da31012c40330e7e21538e7dd57503b16e8a0839159e96137090cccc9910b171"</code>.
|
||||
testString: assert.equal(SHA256("implementation"), "da31012c40330e7e21538e7dd57503b16e8a0839159e96137090cccc9910b171");
|
||||
- text: <code>SHA256("algorithm")</code> should return <code>"b1eb2ec8ac9f31ff7918231e67f96e6deda83a9ff33ed2c67443f1df81e5ed14"</code>.
|
||||
testString: assert.equal(SHA256("algorithm"), "b1eb2ec8ac9f31ff7918231e67f96e6deda83a9ff33ed2c67443f1df81e5ed14");
|
||||
- text: <code>SHA256("language")</code> should return <code>"a4ef304ba42a200bafd78b046e0869af9183f6eee5524aead5dcb3a5ab5f8f3f"</code>.
|
||||
testString: assert.equal(SHA256("language"), "a4ef304ba42a200bafd78b046e0869af9183f6eee5524aead5dcb3a5ab5f8f3f");
|
||||
```js
|
||||
assert(typeof SHA256 === 'function');
|
||||
```
|
||||
|
||||
</section>
|
||||
`SHA256("Rosetta code")` should return a string.
|
||||
|
||||
## Challenge Seed
|
||||
```js
|
||||
assert(typeof SHA256('Rosetta code') === 'string');
|
||||
```
|
||||
|
||||
<section id='challengeSeed'>
|
||||
<div id='js-seed'>
|
||||
`SHA256("Rosetta code")` should return `"764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf"`.
|
||||
|
||||
```js
|
||||
assert.equal(
|
||||
SHA256('Rosetta code'),
|
||||
'764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf'
|
||||
);
|
||||
```
|
||||
|
||||
`SHA256("SHA-256 Hash")` should return `"bee8c0cabdcf8c7835f40217dd35a8b0dba9134520e633f1c57285f35ca7ee3e"`.
|
||||
|
||||
```js
|
||||
assert.equal(
|
||||
SHA256('SHA-256 Hash'),
|
||||
'bee8c0cabdcf8c7835f40217dd35a8b0dba9134520e633f1c57285f35ca7ee3e'
|
||||
);
|
||||
```
|
||||
|
||||
`SHA256("implementation")` should return `"da31012c40330e7e21538e7dd57503b16e8a0839159e96137090cccc9910b171"`.
|
||||
|
||||
```js
|
||||
assert.equal(
|
||||
SHA256('implementation'),
|
||||
'da31012c40330e7e21538e7dd57503b16e8a0839159e96137090cccc9910b171'
|
||||
);
|
||||
```
|
||||
|
||||
`SHA256("algorithm")` should return `"b1eb2ec8ac9f31ff7918231e67f96e6deda83a9ff33ed2c67443f1df81e5ed14"`.
|
||||
|
||||
```js
|
||||
assert.equal(
|
||||
SHA256('algorithm'),
|
||||
'b1eb2ec8ac9f31ff7918231e67f96e6deda83a9ff33ed2c67443f1df81e5ed14'
|
||||
);
|
||||
```
|
||||
|
||||
`SHA256("language")` should return `"a4ef304ba42a200bafd78b046e0869af9183f6eee5524aead5dcb3a5ab5f8f3f"`.
|
||||
|
||||
```js
|
||||
assert.equal(
|
||||
SHA256('language'),
|
||||
'a4ef304ba42a200bafd78b046e0869af9183f6eee5524aead5dcb3a5ab5f8f3f'
|
||||
);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function SHA256(input) {
|
||||
@ -52,12 +82,7 @@ function SHA256(input) {
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
||||
<section id='solution'>
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function SHA256(input) {
|
||||
@ -407,5 +432,3 @@ function SHA256(input) {
|
||||
return hex_sha2(input);
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user