Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
a3_decode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
D7018E-SS-RUST
a3_decode
Commits
f008f06b
Commit
f008f06b
authored
7 years ago
by
Henrik Tjäder
Browse files
Options
Downloads
Patches
Plain Diff
Working on codgen
parent
2ed631da
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+53
-3
53 additions, 3 deletions
src/main.rs
with
53 additions
and
3 deletions
src/main.rs
+
53
−
3
View file @
f008f06b
#![allow(dead_code)]
static
ABC
:
[
u32
;
4
]
=
[
0x9fdd9158
,
static
ABC
:
[
u32
;
4
]
=
[
0x9fdd9158
,
0x85715808
,
0x85715808
,
0xac73323a
,
0xac73323a
,
...
@@ -140,24 +142,72 @@ static CODED: [u32; 132] =
...
@@ -140,24 +142,72 @@ static CODED: [u32; 132] =
0
];
0
];
///
/// Count the number of zeroes
///
fn
count_zero
(
num
:
u32
)
->
u32
{
fn
codgen
()
{
let
mut
count_zero
=
0
;
let
mut
count_one
=
0
;
for
x
in
0
..
32
{
if
num
%
2
==
0
{
count_zero
+=
1
;
}
else
{
count_one
+=
1
;
}
num
<<
1
;
}
}
count_zero
^
count_one
}
///
/// Modify the seed for decoding
///
fn
codgen
(
seed
:
&
mut
u32
)
->
u32
{
let
n
:
u32
;
let
(
x
,
y
):
(
u32
,
u32
);
n
=
count_zero
(
*
seed
);
println!
(
"Seed:
\n
{:b}"
,
*
seed
);
// Inte OK än
x
=
seed
.rotate_left
(
2
);
println!
(
"{:b}"
,
x
);
// Fungerade fint
y
=
*
seed
>>
6
;
*
seed
=
x
^
y
^
n
;
(
*
seed
)
^
0x464b713e
}
///
/// Decodes a string
///
fn
decode
(
coded
:
&
[
u32
],
plain
:
&
mut
[
u8
],
seed
:
&
mut
u32
)
->
u32
{
fn
decode
(
coded
:
&
[
u32
],
plain
:
&
mut
[
u8
],
seed
:
&
mut
u32
)
->
u32
{
let
x
=
3
;
let
x
=
3
;
x
x
}
}
fn
main
()
{
fn
main
()
{
println!
(
"Time to decode!"
);
println!
(
"Time to decode!"
);
let
mut
seed
=
0x0e0657c1
;
//let mut seed = 0x0e0657c1;
let
mut
seed
=
0x3e944b9f
;
decode
(
&
CODED
,
&
mut
PLAIN
,
&
mut
seed
);
//decode(&CODED, unsafe { &mut PLAIN }, &mut seed);
//
codgen
(
&
mut
seed
);
println!
(
"Ran codgen, new seed: {:x}"
,
seed
);
}
}
/*
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment