Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
b67f7e03
Commit
b67f7e03
authored
Jan 17, 2024
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support gen-key --name [ <key_name> ] option, store name in key file.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
e6abc565
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
audiowmark.cc
src/audiowmark.cc
+27
-3
No files found.
src/audiowmark.cc
View file @
b67f7e03
...
...
@@ -56,7 +56,7 @@ print_usage()
printf
(
" audiowmark cmp <watermarked_wav> <message_hex>
\n
"
);
printf
(
"
\n
"
);
printf
(
" * generate 128-bit watermarking key, to be used with --key option
\n
"
);
printf
(
" audiowmark gen-key <key_file>
\n
"
);
printf
(
" audiowmark gen-key <key_file>
[ --name <key_name> ]
\n
"
);
printf
(
"
\n
"
);
printf
(
"Global options:
\n
"
);
printf
(
" -q, --quiet disable information messages
\n
"
);
...
...
@@ -400,9 +400,29 @@ test_resample (const string& in_file, const string& out_file, int new_rate)
return
0
;
}
static
void
check_key_name
(
const
string
&
name
)
{
for
(
auto
ch
:
name
)
{
if
((
ch
>=
'A'
&&
ch
<=
'Z'
)
||
(
ch
>=
'a'
&&
ch
<=
'z'
)
||
(
ch
>=
'0'
&&
ch
<=
'9'
)
||
ch
==
' '
||
ch
==
'-'
||
ch
==
'_'
)
{
// fine
}
else
{
error
(
"audiowmark: bad key name: '%c' is not allowed as character in key names
\n
"
,
ch
);
exit
(
1
);
}
}
}
int
gen_key
(
const
string
&
outfile
)
gen_key
(
const
string
&
outfile
,
const
string
&
key_name
)
{
check_key_name
(
key_name
);
FILE
*
f
=
fopen
(
outfile
.
c_str
(),
"w"
);
if
(
!
f
)
{
...
...
@@ -410,6 +430,8 @@ gen_key (const string& outfile)
return
1
;
}
fprintf
(
f
,
"# watermarking key for audiowmark
\n\n
key %s
\n
"
,
Random
::
gen_key
().
c_str
());
if
(
key_name
!=
""
)
fprintf
(
f
,
"name
\"
%s
\"\n
"
,
key_name
.
c_str
());
fclose
(
f
);
return
0
;
}
...
...
@@ -864,8 +886,10 @@ main (int argc, char **argv)
}
else
if
(
ap
.
parse_cmd
(
"gen-key"
))
{
string
key_name
;
ap
.
parse_opt
(
"--name"
,
key_name
);
args
=
parse_positional
(
ap
,
"key_file"
);
return
gen_key
(
args
[
0
]);
return
gen_key
(
args
[
0
]
,
key_name
);
}
else
if
(
ap
.
parse_cmd
(
"gentest"
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment