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,50 +5,69 @@ challengeType: 5
|
||||
forumTopicId: 385326
|
||||
---
|
||||
|
||||
## Description
|
||||
# --description--
|
||||
|
||||
**SHA-1** or **SHA1** is a one-way hash function; it computes a 160-bit message digest.
|
||||
|
||||
<section id='description'>
|
||||
<b>SHA-1</b> or <b>SHA1</b> is a one-way hash function; it computes a 160-bit message digest.
|
||||
SHA-1 often appears in security protocols; for example, many HTTPS websites use RSA with SHA-1 to secure their connections.
|
||||
|
||||
BitTorrent uses SHA-1 to verify downloads.
|
||||
|
||||
Git and Mercurial use SHA-1 digests to identify commits.
|
||||
A US government standard, <a href="https://rosettacode.org/wiki/SHA-1/FIPS-180-1" target="_blank">FIPS 180-1</a>, defines SHA-1.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
A US government standard, [FIPS 180-1](https://rosettacode.org/wiki/SHA-1/FIPS-180-1), defines SHA-1.
|
||||
|
||||
# --instructions--
|
||||
|
||||
<section id='instructions'>
|
||||
Write a function that returns the SHA-1 message digest for a given string.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
# --hints--
|
||||
|
||||
<section id='tests'>
|
||||
`SHA1` should be a function.
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>SHA1</code> should be a function.
|
||||
testString: assert(typeof SHA1 === 'function');
|
||||
- text: <code>SHA1("abc")</code> should return a string.
|
||||
testString: assert(typeof SHA1("abc") === 'string');
|
||||
- text: <code>SHA1("abc")</code> should return <code>"a9993e364706816aba3e25717850c26c9cd0d89d"</code>.
|
||||
testString: assert.equal(SHA1("abc"), "a9993e364706816aba3e25717850c26c9cd0d89d");
|
||||
- text: <code>SHA1("Rosetta Code")</code> should return <code>"48c98f7e5a6e736d790ab740dfc3f51a61abe2b5"</code>.
|
||||
testString: assert.equal(SHA1("Rosetta Code"), "48c98f7e5a6e736d790ab740dfc3f51a61abe2b5");
|
||||
- text: <code>SHA1("Hello world")</code> should return <code>"7b502c3a1f48c8609ae212cdfb639dee39673f5e"</code>.
|
||||
testString: assert.equal(SHA1("Hello world"), "7b502c3a1f48c8609ae212cdfb639dee39673f5e");
|
||||
- text: <code>SHA1("Programming")</code> should return <code>"d1a946bf8b2f2a7292c250063ee28989d742cd4b"</code>.
|
||||
testString: assert.equal(SHA1("Programming"), "d1a946bf8b2f2a7292c250063ee28989d742cd4b");
|
||||
- text: <code>SHA1("is Awesome")</code> should return <code>"6537205da59c72b57ed3881843c2d24103d683a3"</code>.
|
||||
testString: assert.equal(SHA1("is Awesome"), "6537205da59c72b57ed3881843c2d24103d683a3");
|
||||
```js
|
||||
assert(typeof SHA1 === 'function');
|
||||
```
|
||||
|
||||
</section>
|
||||
`SHA1("abc")` should return a string.
|
||||
|
||||
## Challenge Seed
|
||||
```js
|
||||
assert(typeof SHA1('abc') === 'string');
|
||||
```
|
||||
|
||||
<section id='challengeSeed'>
|
||||
<div id='js-seed'>
|
||||
`SHA1("abc")` should return `"a9993e364706816aba3e25717850c26c9cd0d89d"`.
|
||||
|
||||
```js
|
||||
assert.equal(SHA1('abc'), 'a9993e364706816aba3e25717850c26c9cd0d89d');
|
||||
```
|
||||
|
||||
`SHA1("Rosetta Code")` should return `"48c98f7e5a6e736d790ab740dfc3f51a61abe2b5"`.
|
||||
|
||||
```js
|
||||
assert.equal(SHA1('Rosetta Code'), '48c98f7e5a6e736d790ab740dfc3f51a61abe2b5');
|
||||
```
|
||||
|
||||
`SHA1("Hello world")` should return `"7b502c3a1f48c8609ae212cdfb639dee39673f5e"`.
|
||||
|
||||
```js
|
||||
assert.equal(SHA1('Hello world'), '7b502c3a1f48c8609ae212cdfb639dee39673f5e');
|
||||
```
|
||||
|
||||
`SHA1("Programming")` should return `"d1a946bf8b2f2a7292c250063ee28989d742cd4b"`.
|
||||
|
||||
```js
|
||||
assert.equal(SHA1('Programming'), 'd1a946bf8b2f2a7292c250063ee28989d742cd4b');
|
||||
```
|
||||
|
||||
`SHA1("is Awesome")` should return `"6537205da59c72b57ed3881843c2d24103d683a3"`.
|
||||
|
||||
```js
|
||||
assert.equal(SHA1('is Awesome'), '6537205da59c72b57ed3881843c2d24103d683a3');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function SHA1(input) {
|
||||
@ -56,12 +75,7 @@ function SHA1(input) {
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
|
||||
<section id='solution'>
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function SHA1(input) {
|
||||
@ -163,5 +177,3 @@ function SHA1(input) {
|
||||
return hex_sha1(input);
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user