OpenWebNet password: Difference between revisions

m
syntax highlighting fixup automation
m (→‎{{header|Phix}}: syntax coloured, made p2js compatible)
m (syntax highlighting fixup automation)
Line 18:
{{trans|Nim}}
 
<langsyntaxhighlight lang="11l">F ownCalcPass(password, nonce)
UInt32 result
V start = 1B
Line 61:
test_passwd_calc(‘12345’, ‘603356072’, 25280520)
test_passwd_calc(‘12345’, ‘410501656’, 119537670)
test_passwd_calc(‘12345’, ‘630292165’, 4269684735)</langsyntaxhighlight>
 
{{out}}
Line 72:
=={{header|D}}==
{{trans|Python}}
<langsyntaxhighlight lang="d">import std.stdio, std.string, std.conv, std.ascii, std.algorithm;
 
ulong ownCalcPass(in ulong password, in string nonce)
Line 198:
ownTestCalcPass("12345", "603356072", 25280520UL);
ownTestCalcPass("12345", "410501656", 119537670UL);
}</langsyntaxhighlight>
{{out}}
<pre>PASS 12345 603356072 25280520 25280520
Line 206:
{{libheader| System.SysUtils}}
{{Trans|Go}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program OpenWebNet_password;
 
Line 307:
testPasswordCalc('12345', '630292165', 4269684735);
readln;
end.</langsyntaxhighlight>
 
=={{header|Go}}==
{{trans|Python}}
<langsyntaxhighlight lang="go">package main
 
import (
Line 388:
testPasswordCalc("12345", "410501656", 119537670)
testPasswordCalc("12345", "630292165", 4269684735)
}</langsyntaxhighlight>
 
{{out}}
Line 398:
 
=={{header|JavaScript}}==
<langsyntaxhighlight lang="javascript">
function calcPass (pass, nonce) {
var flag = true;
Line 488:
testCalcPass ('12345', '630292165', '4269684735');
testCalcPass ('12345', '523781130', '537331200');
</syntaxhighlight>
</lang>
 
=={{header|Julia}}==
Passes all tests.
<langsyntaxhighlight lang="julia">function calcpass(passwd, nonce::String)
startflag = true
n1 = 0
Line 540:
 
testcalcpass()
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
{{trans|Python}}
<langsyntaxhighlight lang="scala">// version 1.1.51
 
fun ownCalcPass(password: Long, nonce: String): Long {
Line 655:
ownTestCalcPass("12345", "603356072", 25280520)
ownTestCalcPass("12345", "410501656", 119537670)
}</langsyntaxhighlight>
 
{{out}}
Line 665:
=={{header|Nim}}==
{{trans|Python}}
<langsyntaxhighlight Nimlang="nim">import bitops, strutils
 
func ownCalcPass(password, nonce: string): uint32 =
Line 711:
testPasswordCalc("12345", "603356072", 25280520u32)
testPasswordCalc("12345", "410501656", 119537670u32)
testPasswordCalc("12345", "630292165", 4269684735u32)</langsyntaxhighlight>
 
{{out}}
Line 720:
=={{header|Perl}}==
{{trans|Raku}}
<langsyntaxhighlight lang="perl">use strict;
use warnings;
use feature 'say';
Line 767:
say own_password( 12345, 603356072 );
say own_password( 12345, 410501656 );
say own_password( 12345, 630292165 );</langsyntaxhighlight>
{{out}}
<pre>25280520
Line 774:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">ownCalcPass</span><span style="color: #0000FF;">(</span><span style="color: #004080;">atom</span> <span style="color: #000000;">pwd</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">string</span> <span style="color: #000000;">nonce</span><span style="color: #0000FF;">)</span>
Line 828:
<span style="color: #000000;">testPasswordCalc</span><span style="color: #0000FF;">(</span><span style="color: #000000;">12345</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"630292165"</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">4269684735</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">testPasswordCalc</span><span style="color: #0000FF;">(</span><span style="color: #000000;">12345</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"523781130"</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">537331200</span><span style="color: #0000FF;">)</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 838:
 
=={{header|PHP}}==
<langsyntaxhighlight PHPlang="php">function ownCalcPass($password, $nonce) {
$msr = 0x7FFFFFFF;
$m_1 = (int)0xFFFFFFFF;
Line 966:
return sprintf('%u', $num1 & $m_1);
}
</syntaxhighlight>
</lang>
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">
def ownCalcPass (password, nonce, test=False) :
start = True
Line 1,035:
test_passwd_calc('12345','630292165','4269684735')
 
</syntaxhighlight>
</lang>
 
=={{header|Racket}}==
Line 1,041:
{{trans|Python}} (followed by some aggressive refactoring)
 
<langsyntaxhighlight lang="racket">#lang racket/base
(define (32-bit-truncate n)
(bitwise-and n #xFFFFFFFF))
Line 1,098:
(own-test-calc-pass "12345" "603356072" 25280520)
(own-test-calc-pass "12345" "410501656" 119537670))</langsyntaxhighlight>
 
=={{header|Raku}}==
Line 1,104:
 
Raku doesn't really have good support for unsigned fixed bit integers yet so emulating them with regular Ints and bitmasks.
<syntaxhighlight lang="raku" perl6line>sub own-password (Int $password, Int $nonce) {
my int $n1 = 0;
my int $n2 = $password;
Line 1,156:
say own-password( 12345, 603356072 );
say own-password( 12345, 410501656 );
say own-password( 12345, 630292165 );</langsyntaxhighlight>
 
{{out}}
Line 1,164:
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">
func openAuthenticationResponse(_password: String, operations: String) -> String? {
var num1 = UInt32(0)
Line 1,217:
return String(num1)
}
</syntaxhighlight>
</lang>
 
=={{header|Wren}}==
{{trans|Python}}
{{libheader|Wren-fmt}}
<langsyntaxhighlight lang="ecmascript">import "/fmt" for Fmt
 
var ownCalcPass = Fn.new { |password, nonce|
Line 1,285:
testPasswordCalc.call("12345", "603356072", 25280520)
testPasswordCalc.call("12345", "410501656", 119537670)
testPasswordCalc.call("12345", "630292165", 4269684735)</langsyntaxhighlight>
 
{{out}}
10,333

edits